Forgot password?
 Create new account
View 1421|Reply 4

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

[Copy link]

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

kuing Posted at 2018-6-23 14:03:20 |Read mode
问题来自:bbs.ctex.org/forum.php?mod=viewthread&tid=155195
要画这样的图:
QQ截图20180623134918.jpg

解:为了使阴影与图中完全一样,需加载 \usetikzlibrary{patterns},然后:
  1. \begin{tikzpicture}
  2. \begin{scope}
  3. \clip (0,0) arc (-90:0:2) arc (90:180:2);
  4. \fill[pattern=horizontal lines]
  5. (0,0) arc (-90:0:2) --(1,1) arc (90:0:1);
  6. \fill[pattern=vertical lines]
  7. (0,0) arc (180:90:2) --(1,1) arc (0:90:1);
  8. \end{scope}
  9. \draw[->](-0.5,0)--(4.5,0)node[below]{$x$};
  10. \draw[->](0,-0.5)--(0,4.5)node[left]{$y$};
  11. \draw (0,0) arc (-90:90:2) (0,0) arc (-90:90:1)
  12. (0,0) arc (180:0:2) (0,0) arc (180:0:1) (0,0)--(2,2);
  13. \end{tikzpicture}
Copy the Code

效果:


解释:由 fill 的特性,\fill[pattern=horizontal lines](0,0) arc (-90:0:2) --(1,1) arc (90:0:1); 这一句所填充的是这样的区域:

然后由于前面有个 clip,就只剩上面那块了,另一边同理。

801

Threads

4889

Posts

310K

Credits

Credits
36169

Show all posts

isee Posted at 2018-6-23 17:15:59
回复 1# kuing

这种阴影在常见的几种数学作图软件中都很麻烦
有个类似的链接

701

Threads

110K

Posts

910K

Credits

Credits
94172
QQ

Show all posts

 Author| kuing Posted at 2018-6-23 17:23:41
回复 2# isee

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

801

Threads

4889

Posts

310K

Credits

Credits
36169

Show all posts

isee Posted at 2018-6-27 23:43:18
回复 3# kuing


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

3147

Threads

8493

Posts

610K

Credits

Credits
66163
QQ

Show all posts

hbghlyj Posted at 2023-7-30 14:27:51
Last edited by hbghlyj at 2023-7-30 14:40:00Asymptote使用buildcycle

手机版Mobile version|Leisure Math Forum

2025-4-20 22:18 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list