我想用 Tikz 画一面镜子及其厚度。我将向你展示我想要实现的最终结果
我设法编写了此代码(使用 tikz 包)
\shade[shading angle= 90] (75:3)
-- (75:3.5) arc (75:-75:3.5)
-- (-75:3) arc (-75:75:3);
我希望有不同的阴影效果,如环形阴影。有人能帮我吗?提前谢谢。
附录:我真的很生气。我试图将内部颜色与外部颜色交换以获得这种效果
但实际上乳胶给我的回报是
我会给你我使用的代码
\tikzfading[name=fade out,inner color=transparent!100,outer color=transparent!0]
\begin{scope}[xshift=6cm]
\clip (75:-3)
-- (75:-2.5) arc (75:-75:-2.5)
-- (-75:-3) arc (-75:75:-3);
\fill[path fading=fade out] (0,0) circle[radius=-3];
\end{scope}
如果我像以前一样保留外部和内部颜色,我会得到这个
我不明白为什么 tikz 会这样。理论上,如果我交换颜色,我应该得到我应该得到的东西,但我显然错了,我不知道为什么。
答案1
欢迎!以下是 pgfmanual 中的两个基本选项:
circle with fuzzy edge 15 percent
fade out
例子:
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{fadings}
\tikzfading[name=fade out,inner color=transparent!0,outer color=transparent!100]
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (75:3)
-- (75:3.5) arc (75:-75:3.5)
-- (-75:3) arc (-75:75:3);
\fill[path fading=circle with fuzzy edge 15 percent] (0,0) circle[radius=3.5cm];
\end{scope}
\begin{scope}[xshift=5cm]
\clip (75:3)
-- (75:3.5) arc (75:-75:3.5)
-- (-75:3) arc (-75:75:3);
\fill[path fading=fade out] (0,0) circle[radius=3.5cm];
\end{scope}
\end{tikzpicture}
\end{document}
您可以按如下方式使用此功能:
\documentclass[tikz,border=3mm]{standalone}
\usepackage{contour}
\contourlength{0.05em}
\usetikzlibrary{fadings,decorations.markings,calc,angles,quotes}
\tikzset{->-/.style={decoration={% https://tex.stackexchange.com/a/39282/194703
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}},
->-/.default=0.5}
\begin{document}
\begin{tikzpicture}[>=stealth,every label/.append style={black},
bullet/.style={circle,fill=black,inner sep=0.1em}]
\begin{scope}
\clip (75:3)
-- (75:3.5) arc (75:-75:3.5)
-- (-75:3) arc (-75:75:3);
\fill[path fading=circle with fuzzy edge 15 percent] (0,0) circle[radius=3.5cm];
\end{scope}
\draw (-3,0) coordinate (L) -- (4,0) coordinate (R) (3,0)
node[bullet,label=below right:\contour{white}{$V$}](V){};
\pgfmathsetmacro{\myangle}{atan2(3*sin(30),2+3*cos(30))}
\draw[thick,orange,->-] (-2,0) node[bullet,label=below:$O$](O){}
-- (30:3) node[bullet,label={above right:\contour{white}{$P$}}] (P){};
\draw[dashed,blue] (0,0) node[bullet,label=below:$C$] (C){} -- (P);
\path[overlay] (P) -- ++ (180+60-\myangle:1) coordinate (Q);
\draw[thick,red,->-] (P) --
(intersection cs:first line={(L)--(R)}, second line={(P)--(Q)})
node[bullet,label=below:$I$] (I){};
\path[blue]
pic [draw, "$\scriptstyle\alpha$",angle eccentricity=1.25,angle radius=1cm] {angle=R--O--P}
pic [draw, "$\scriptstyle\beta$",angle eccentricity=0.7,angle radius=0.8cm] {angle=R--C--P}
pic [draw, "$\scriptstyle\gamma$",angle eccentricity=0.7,angle radius=0.8cm] {angle=R--I--P};
\end{tikzpicture}
\end{document}
或者声明你自己的。
\documentclass[tikz,border=3mm]{standalone}
\usepackage{contour}
\contourlength{0.05em}
\usetikzlibrary{fadings,decorations.markings,calc,angles,quotes}
\pgfdeclareradialshading{invircle}{\pgfpointorigin}{
color(0pt)=(pgftransparent!100); color(22.5bp)=(pgftransparent!80);
color(25bp)=(pgftransparent!20); color(50bp)=(pgftransparent!00)}%
\pgfdeclarefading{inverted fading}{\pgfuseshading{invircle}}%
\tikzset{->-/.style={decoration={% https://tex.stackexchange.com/a/39282/194703
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}},
->-/.default=0.5}
\begin{document}
\begin{tikzpicture}[>=stealth,every label/.append style={black},
bullet/.style={circle,fill=black,inner sep=0.1em}]
\begin{scope}
\clip (75:3)
-- (75:3.5) arc (75:-75:3.5)
-- (-75:3) arc (-75:75:3);
\fill[path fading=inverted fading] (0,0) circle[radius=3.5cm];
\end{scope}
\draw (-3,0) coordinate (L) -- (4,0) coordinate (R) (3,0)
node[bullet,label=below right:\contour{white}{$V$}](V){};
\pgfmathsetmacro{\myangle}{atan2(3*sin(30),2+3*cos(30))}
\draw[thick,orange,->-] (-2,0) node[bullet,label=below:$O$](O){}
-- (30:3) node[bullet,label={above right:\contour{white}{$P$}}] (P){};
\draw[dashed,blue] (0,0) node[bullet,label=below:$C$] (C){} -- (P);
\path[overlay] (P) -- ++ (180+60-\myangle:1) coordinate (Q);
\draw[thick,red,->-] (P) --
(intersection cs:first line={(L)--(R)}, second line={(P)--(Q)})
node[bullet,label=below:$I$] (I){};
\path[blue]
pic [draw, "$\scriptstyle\alpha$",angle eccentricity=1.25,angle radius=1cm] {angle=R--O--P}
pic [draw, "$\scriptstyle\beta$",angle eccentricity=0.7,angle radius=0.8cm] {angle=R--C--P}
pic [draw, "$\scriptstyle\gamma$",angle eccentricity=0.7,angle radius=0.8cm] {angle=R--I--P};
\end{tikzpicture}
\end{document}
附录:关于你问题的补充:这里有一个阴影,它会产生类似的东西。它是通过查找和的定义circle with fuzzy edge 10 percent
来“反转”而获得的,正如你建议的那样。
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{decorations.markings,calc,angles,quotes}
\pgfdeclareradialshading{halo}{\pgfpointorigin}{
color(0pt)=(pgftransparent!100); color(22.5bp)=(pgftransparent!100);
color(25bp)=(pgftransparent!00); color(50bp)=(pgftransparent!00)}%
\pgfdeclarefading{halo}{\pgfuseshading{halo}}%
\tikzset{->-/.style={decoration={% https://tex.stackexchange.com/a/39282/194703
markings,
mark=at position #1 with {\arrow{>}}},postaction={decorate}},
->-/.default=0.5}
\begin{document}
\begin{tikzpicture}[>=stealth,every label/.append style={black},
bullet/.style={circle,fill=black,inner sep=0.1em}]
\begin{scope}[xshift=6cm]
\clip (75:-3)
-- (75:-2.5) arc (75:-75:-2.5)
-- (-75:-3) arc (-75:75:-3);
\fill[path fading=halo] (0,0) circle[radius=3cm];
\end{scope}
\draw (-2,0) coordinate (L) -- (7,0) coordinate (R)
(3,0) node[bullet,label=below left:$V$](V){}
(6,0) node[bullet,label=below:$C$](C){}
(-1,0) node[bullet,label=below:$O$](O){}
($(C)+(160:3)$) node[bullet,label=above:$P$](P){};
\draw[orange,->-,thick] (O) -- (P);
\draw[red,->-,thick] let \p1=($(P)-(C)$),\p2=($(P)-(O)$),
\n1={180-atan2(\y1,\x1)},\n2={atan2(\y2,\x2)} in
(P) -- ++({180-(2*\n1+\n2)}:2);
\draw[dashed, shorten >=-2cm] (C) -- (P);
\end{tikzpicture}
\end{document}