如何修改下面的代码,以便用黄色突出显示的区域可以被阴影化?
\documentclass[]{article}
\usepackage[margin=0.5in]{geometry}
\usepackage{pgfplots}
\renewcommand{\thesection}{\arabic{section}}
\usepackage{mathtools}
\usepackage{cancel}
\usepackage{pgfplots}
\usepackage{amsmath}
\newtheorem{theorem}{THEOREM}
\newtheorem{proof}{PROOF}
\usepackage{tikz}
\usepackage{amssymb}
\usetikzlibrary{patterns}
\usepackage{fancyhdr}
\usepackage{bigints}
\usepackage{color}
\usepackage{tcolorbox}
\usepackage{color,xcolor}
\usepackage{booktabs,array}
\usepackage{hyperref}
\usepackage{graphicx}
\usetikzlibrary{arrows}
\usepackage{polynom}
\usepackage{wallpaper}
\usepackage{flexisym}
\usepackage{caption}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{arrows.meta}
\usepgfplotslibrary{fillbetween}
\usepgfplotslibrary{statistics}
\newenvironment{tightcenter}{
\setlength\topsep{0pt}
\setlength\parskip{0pt}
\begin{center}}{\end{center}}
\begin{document}
\begin{tikzpicture}
\draw[thick] (0,0) circle (1.5cm);
\draw[thick,red] (-1.34,-0.7) -- (+1.34,-0.7);
%
%\draw[blue] (-1.34,-0.7) arc (240:290:2.3cm);
\end{tikzpicture}
\end{document}
答案1
有很多可能性,包括计算弧角、使用剪辑或使用path picture
。
\documentclass[tikz,border=3mm]{standalone}
\begin{document}
\begin{tikzpicture}[declare function={r=1.5;alpha=asin(-0.7/r);}]
\begin{scope}[local bounding box=w/o clip]
\draw[thick] (0,0) circle[radius=r];
\fill[yellow] (180-alpha:r) -- (alpha:r) arc[start angle=alpha,end
angle=-180-alpha,radius=r];
\draw[thick,red] (180-alpha:r) -- (alpha:r);
\end{scope}
%
\begin{scope}[xshift=r*2.5cm,local bounding box=w/ clip]
\draw[thick] (0,0) circle[radius=r];
\clip (0,0) circle[radius=r*1cm-0.3pt];
\fill[yellow] (-r,-0.7) rectangle (r,-r);
\draw[thick,red] (-r,-0.7) -- (r,-0.7);
\end{scope}
%
\begin{scope}[xshift=r*5cm,local bounding box=path picture]
\draw[thick,path picture={
\fill[yellow] ([yshift=-0.7cm]path picture bounding box.west)
rectangle (path picture bounding box.south east);
\draw[thick,red] ([yshift=-0.7cm]path picture bounding box.west)
-- ([yshift=-0.7cm]path picture bounding box.east);
}] (0,0) circle[radius=r];
\end{scope}
%
\path foreach \X in {w/o clip,w/ clip,path picture}
{(\X|-0,-r) node[below=1ex,font=\sffamily]{\X}};
\end{tikzpicture}
\end{document}
path picture
如果将圆设为节点,效果也一样。但请注意,这些带 s 的节点并不path picture
总是能与旋转等变换很好地协作。