悠闲数学娱乐论坛(第2版)'s Archiver

kuing 发表于 2018-6-23 14:03

阴影填充一例,fill 的特性 + clip

问题来自:[url]http://bbs.ctex.org/forum.php?mod=viewthread&tid=155195[/url]
要画这样的图:
[attach]6379[/attach]

解:为了使阴影与图中完全一样,需加载 \usetikzlibrary{patterns},然后:[code]\begin{tikzpicture}
\begin{scope}
\clip (0,0) arc (-90:0:2) arc (90:180:2);
\fill[pattern=horizontal lines]
(0,0) arc (-90:0:2) --(1,1) arc (90:0:1);
\fill[pattern=vertical lines]
(0,0) arc (180:90:2) --(1,1) arc (0:90:1);
\end{scope}
\draw[->](-0.5,0)--(4.5,0)node[below]{$x$};
\draw[->](0,-0.5)--(0,4.5)node[left]{$y$};
\draw (0,0) arc (-90:90:2) (0,0) arc (-90:90:1)
(0,0) arc (180:0:2) (0,0) arc (180:0:1) (0,0)--(2,2);
\end{tikzpicture}[/code]效果:
[attach]6380[/attach]

解释:由 fill 的特性,\fill[pattern=horizontal lines](0,0) arc (-90:0:2) --(1,1) arc (90:0:1); 这一句所填充的是这样的区域:
[attach]6381[/attach]
然后由于前面有个 clip,就只剩上面那块了,另一边同理。

isee 发表于 2018-6-23 17:15

[b]回复 [url=http://kuing.orzweb.net/redirect.php?goto=findpost&pid=27266&ptid=5444]1#[/url] [i]kuing[/i] [/b]

这种阴影在常见的几种数学作图软件中都很麻烦
有个[url=https://tex.stackexchange.com/questions/328562/fill-a-section-between-two-circles-with-tikz]类似的链接[/url]

kuing 发表于 2018-6-23 17:23

[b]回复 [url=http://kuing.orzweb.net/redirect.php?goto=findpost&pid=27267&ptid=5444]2#[/url] [i]isee[/i] [/b]

链接那个太简单,clip 一下搞定啊
不用 clip 也行,直接填绿圆,再用白的大圆盖住就行了,当然这不及 clip 那么好,因为背景不一定是白的

isee 发表于 2018-6-27 23:43

[b]回复 [url=http://kuing.orzweb.net/redirect.php?goto=findpost&pid=27268&ptid=5444]3#[/url] [i]kuing[/i] [/b]


正是因为比你的简单才链接的,嘿嘿,好入门。

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.