我刚刚做了下图:
使用以下代码:
\documentclass[preview]{standalone}
\usepackage{tikz}
\makeatletter
\pgfdeclareradialshading[tikz@ball]{ball}{\pgfqpoint{-10bp}{10bp}}{%
color(0bp)=(gray!20);
color(9bp)=(gray!30);
color(18bp)=(gray!50);
color(25bp)=(gray!50);
color(50bp)=(gray)}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw[-stealth,color=gray!30!black,very thick] (1,-0.6) -- (1,0.65);
\filldraw[color=black, fill opacity=0,thick](1,0) circle (0.4);
\shade [ball color=white] (1,0) circle (0.4);
\end{tikzpicture}
\end{document}
我想制作一个像下面红色箭头一样的箭头:
答案1
以下是箭头第一部分的示例:
\documentclass[tikz, border=5pt, multi]{standalone}
\pgfdeclareradialshading[myballcolour]{my ball}{\pgfpoint{-10bp}{10bp}}{%
color(0bp)=(myballcolour!20);
color(9bp)=(myballcolour!30);
color(18bp)=(myballcolour!50);
color(25bp)=(myballcolour!50);
color(50bp)=(myballcolour)}
\tikzset{%
my ball colour/.code={%
\colorlet{myballcolour}{#1}
},
my ball/.style={%
my ball colour=#1,
shading=my ball,
}
}
\begin{document}
\begin{tikzpicture}
\draw [-stealth, color=gray!30!black, very thick] (1,-0.6) -- (1,0.65);
\node (n) [my ball=yellow, circle, thick, draw=gray!30!black, minimum size=23.5bp] at (1,0) {};
\draw [fill=red] (n.160) ++(175:1.5pt) .. controls +(-.15,-.025) and +(-.35,0) .. ([yshift=-1.5pt,xshift=-5pt]n.center) -- ++(0,1pt) -- ++(2.5pt,-1.5pt) -- ++(-2.5pt,-1.5pt) -- ++(0,1pt) .. controls +(-.35,0) and +(-.15,-.025) .. cycle ;
\end{tikzpicture}
\end{document}
为了确保其他部分匹配,您可以绘制整条曲线并进行适当裁剪。例如:
\documentclass[tikz, border=5pt, multi]{standalone}
\pgfdeclareradialshading[myballcolour]{my ball}{\pgfpoint{-10bp}{10bp}}{%
color(0bp)=(myballcolour!20);
color(9bp)=(myballcolour!30);
color(18bp)=(myballcolour!50);
color(25bp)=(myballcolour!50);
color(50bp)=(myballcolour)}
\tikzset{%
my ball colour/.code={%
\colorlet{myballcolour}{#1}
},
my ball/.style={%
my ball colour=#1,
shading=my ball,
}
}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw [-stealth, color=gray!30!black, very thick] (1,-0.6) -- (1,0.65);
\node (n) [my ball=yellow, circle, thick, draw=gray!30!black, minimum size=23.5bp] at (1,0) {};
\draw [fill=red] (n.160) ++(175:1.5pt) .. controls +(-.15,-.025) and +(-.5,0) .. ([yshift=-2.5pt,xshift=-1.5pt]n.center) -- ++(0,1pt) -- ++(3pt,-1.5pt) -- ++(-3pt,-1.5pt) -- ++(0,1pt) .. controls +(-.5,0) and +(-.15,-.025) .. cycle ;
\begin{scope}
\clip ([xshift=3pt]n.center) |- ($(n.20)+(5:5pt)$) -- ($(n.-20)+(5:5pt)$) -| cycle;
\draw [fill=red] (n.160) ++(175:1.5pt) .. controls +(-.15,-.025) and +(-.5,0) .. ([yshift=-2.5pt,xshift=-1.5pt]n.center) -- ++(3pt,0) .. controls +(.5,0) and +(.15,-.025) .. ($(n.20)+(5:1.5pt)$) .. controls +(.15,-.025) and +(.5,0) .. ([yshift=-3.5pt,xshift=1.5pt]n.center) -- ++(-3pt,0) .. controls +(-.5,0) and +(-.15,-.025) .. cycle ;
\end{scope}
\draw ([yshift=-2.5pt,xshift=3pt]n.center) ++(0,.5pt) ++(.5\pgflinewidth,-\pgflinewidth) -- ++(0,-1pt);
\end{tikzpicture}
\end{document}
生产
编辑
这是生成注释中要求的版本的方法,它会反转箭头。它还会将图片变成pic
具有可配置颜色和(某种程度上)大小的图片。语法是
atom
为默认值或
atom={<options>}
否则。可用选项包括
colour=<atom's colour>
orbit=<orbital arrow's colour>
size=<size of atom>
reverse=true|false
reverse
没有值将被设置reverse=true
。然后我们可以写
\begin{tikzpicture}
\pic {atom};
\begin{scope}[xshift=40bp]
\pic {atom={colour=blue, orbit=magenta, reverse}};
\end{scope}
\end{tikzpicture}
生产
代码:
\documentclass[tikz, border=5pt, multi]{standalone}
\pgfdeclareradialshading[myballcolour]{my ball}{\pgfpoint{-10bp}{10bp}}{%
color(0bp)=(myballcolour!20);
color(9bp)=(myballcolour!30);
color(18bp)=(myballcolour!50);
color(25bp)=(myballcolour!50);
color(50bp)=(myballcolour)}
\newif\iforbitreverse
\tikzset{%
my ball colour/.code={%
\colorlet{myballcolour}{#1}
},
my ball/.style={%
my ball colour=#1,
shading=my ball,
},
pics/atom/.style={%
code={%
\tikzset{%
atom/.cd,
#1
}
\draw [-stealth, color=gray!30!black, very thick] (0,-.725*\atomsize) -- (0,.79*\atomsize);
\node (n) [my ball=\atomcol, circle, thick, draw=gray!30!black, minimum size=\atomsize] at (0,0) {};
\iforbitreverse
\draw [fill=\orbitcol] (n.20) ++(35:1.5pt) .. controls +(.15,-.025) and +(.5,0) .. ([yshift=-2.5pt,xshift=1.5pt]n.center) -- ++(0,1pt) -- ++(-3pt,-1.5pt) -- ++(3pt,-1.5pt) -- ++(0,1pt) .. controls +(.5,0) and +(.15,-.025) .. cycle ;
\begin{scope}
\clip ([xshift=-3pt]n.center) |- ($(n.160)+(175:5pt)$) -- ($(n.-160)+(175:5pt)$) -| cycle;
\draw [fill=\orbitcol] (n.20) ++(35:1.5pt) .. controls +(.15,-.025) and +(.5,0) .. ([yshift=-2.5pt,xshift=1.5pt]n.center) -- ++(-3pt,0) .. controls +(-.5,0) and +(-.15,-.025) .. ($(n.160)+(175:1.5pt)$) .. controls +(-.15,-.025) and +(-.5,0) .. ([yshift=-3.5pt,xshift=-1.5pt]n.center) -- ++(3pt,0) .. controls +(.5,0) and +(.15,-.025) .. cycle ;
\end{scope}
\draw ([yshift=-2.5pt,xshift=-3pt]n.center) ++(0,.5pt) ++(-.5\pgflinewidth,-\pgflinewidth) -- ++(0,-1pt);
\else
\draw [fill=\orbitcol] (n.160) ++(175:1.5pt) .. controls +(-.15,-.025) and +(-.5,0) .. ([yshift=-2.5pt,xshift=-1.5pt]n.center) -- ++(0,1pt) -- ++(3pt,-1.5pt) -- ++(-3pt,-1.5pt) -- ++(0,1pt) .. controls +(-.5,0) and +(-.15,-.025) .. cycle ;
\begin{scope}
\clip ([xshift=3pt]n.center) |- ($(n.20)+(5:5pt)$) -- ($(n.-20)+(5:5pt)$) -| cycle;
\draw [fill=\orbitcol] (n.160) ++(175:1.5pt) .. controls +(-.15,-.025) and +(-.5,0) .. ([yshift=-2.5pt,xshift=-1.5pt]n.center) -- ++(3pt,0) .. controls +(.5,0) and +(.15,-.025) .. ($(n.20)+(5:1.5pt)$) .. controls +(.15,-.025) and +(.5,0) .. ([yshift=-3.5pt,xshift=1.5pt]n.center) -- ++(-3pt,0) .. controls +(-.5,0) and +(-.15,-.025) .. cycle ;
\end{scope}
\draw ([yshift=-2.5pt,xshift=3pt]n.center) ++(0,.5pt) ++(.5\pgflinewidth,-\pgflinewidth) -- ++(0,-1pt);
\fi
}
},
atom/.search also={/tikz},
atom/.cd,
colour/.store in=\atomcol,
size/.store in=\atomsize,
orbit/.store in=\orbitcol,
reverse/.is if=orbitreverse,
colour=yellow,
size=23.5bp,
orbit=red,
reverse=false,
}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\pic {atom};
\begin{scope}[xshift=40bp]
\pic {atom={colour=blue, orbit=magenta, reverse}};
\end{scope}
\end{tikzpicture}
\end{document}