找回密码
 快速注册
搜索
查看: 1313|回复: 4

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

[复制链接]

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

kuing 发表于 2018-6-23 14:03 |阅读模式
问题来自: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}
复制代码

效果:


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

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

830

主题

4862

回帖

3万

积分

积分
36159

显示全部楼层

isee 发表于 2018-6-23 17:15
回复 1# kuing

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

730

主题

1万

回帖

9万

积分

积分
93593
QQ

显示全部楼层

 楼主| kuing 发表于 2018-6-23 17:23
回复 2# isee

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

830

主题

4862

回帖

3万

积分

积分
36159

显示全部楼层

isee 发表于 2018-6-27 23:43
回复 3# kuing


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

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2023-7-30 14:27
本帖最后由 hbghlyj 于 2023-7-30 14:40 编辑 Asymptote使用buildcycle
size(5cm);
import patterns;
add("horizontal",hatch(1mm,E));
add("vertical",hatch(1mm,N));
draw(Label("$y$",1.2),.5S--4.5N,Arrow);
draw(Label("$x$",1.2),.5W--4.5E,E,Arrow);
draw((0,0)--(2,2));
draw(arc(2N,2,-90,90));
draw(arc(N,1,-90,90));
draw(arc(2E,2,0,180));
draw(arc(E,1,0,180));
fill(buildcycle(arc(2N,2,-90,0),(2,2)--(1,1),arc(E,1,90,0)), pattern("horizontal"));
fill(buildcycle(arc(2E,2,180,90),(2,2)--(1,1),arc(N,1,0,90)), pattern("vertical"));

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 12:23

Powered by Discuz!

× 快速回复 返回顶部 返回列表