Forgot password?
 Register account
View 1580|Reply 4

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

[Copy link]

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2018-6-23 14:03 |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,就只剩上面那块了,另一边同理。

768

Threads

4685

Posts

310K

Credits

Credits
35004

Show all posts

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

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

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

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

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

768

Threads

4685

Posts

310K

Credits

Credits
35004

Show all posts

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


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

3153

Threads

7906

Posts

610K

Credits

Credits
64096
QQ

Show all posts

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

Mobile version|Discuz Math Forum

2025-6-5 01:34 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit