Forgot password?
 Create new account
View 181|Reply 12

请教clip边界的颜色怎么做?

[Copy link]

418

Threads

1627

Posts

110K

Credits

Credits
11886

Show all posts

abababa Posted at 2024-12-13 17:54:43 |Read mode
如下代码,我想画的图的边界被填成黑色了,怎么能让边界变成蓝色的呢?
  1. \begin{tikzpicture}[scale=1,label style/.style={font=\scriptsize}]
  2. \clip[draw] (0,3) -- (1,3) -- (1,2) -- (4,2) -- (4,1) -- (5,1) -- (5,0) -- (0,0) -- cycle;
  3. \draw[help lines, color=blue] (0,0) grid (5,3);
  4. \end{tikzpicture}
Copy the Code

701

Threads

110K

Posts

910K

Credits

Credits
94145
QQ

Show all posts

kuing Posted at 2024-12-13 18:34:46
没想到,\clip[draw=blue] 竟然是不行的……

可以在第一行的中括号里加一个 blue

418

Threads

1627

Posts

110K

Credits

Credits
11886

Show all posts

 Author| abababa Posted at 2024-12-13 19:43:08
kuing 发表于 2024-12-13 18:34
没想到,\clip[draw=blue] 竟然是不行的……

可以在第一行的中括号里加一个 blue ...
我刚才想了一下,在之前把那个边画出来也行。
  1. \begin{tikzpicture}[scale=0.5,label style/.style={font=\scriptsize}]
  2. \path[save path=\pathA] (0,3) -- (1,3) -- (1,2) -- (4,2) -- (4,1) -- (5,1) -- (5,0) -- (0,0) -- cycle;
  3. \draw[color=blue][use path=\pathA];
  4. \clip[use path=\pathA];
  5. \draw[help lines, color=blue] (0,0) grid (5,3);
  6. \end{tikzpicture}
Copy the Code

这个clip挺好用的啊,搜索发现还能画集合那种相交的阴影之类的。

Comment

嗯这样也挺好,还善用了 save path 👍  Posted at 2024-12-13 20:04

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2024-12-13 19:56:56
kuing 发表于 2024-12-13 10:34
没想到,\clip[draw=blue] 竟然是不行的……

可以在第一行的中括号里加一个 blue ...
There is a slightly annoying catch: You cannot specify certain graphic options for the command used for clipping. For example, in the above code we could not have moved the fill=red to the \fill command. The reasons for this have to do with the internals of the pdf specification. You do not want to know the details. It is best simply not to specify any options for these commands.
tikz.dev/tikz-actions#pgf./tikz/clip

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2024-12-13 20:02:34
abababa 发表于 2024-12-13 11:43
我刚才想了一下,在之前把那个边画出来也行。
Just use preaction.
\path[preaction={clip},draw=black,postaction={fill=black, draw=white, line width=6mm}]
extra options not allowed for clipping path command

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2024-12-13 20:08:43
abababa 发表于 2024-12-13 09:54
label style/.style={font=\scriptsize}
label style是什么呢?

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2024-12-13 20:19:58
abababa 发表于 2024-12-13 11:43
我刚才想了一下,在之前把那个边画出来也行。
确实和顺序有关!
在clip之前把那个边画出来的效果(局部):
Screenshot 2024-12-13 121904.png
在clip之后把那个边画出来的效果(局部):
Screenshot 2024-12-13 121930.png

418

Threads

1627

Posts

110K

Credits

Credits
11886

Show all posts

 Author| abababa Posted at 2024-12-13 20:33:17
hbghlyj 发表于 2024-12-13 20:08
label style是什么呢?
我现在也不知道这是什么了,这些都是以前我和maven讨论的时候加的一些参数,后来他把这个做到他那个tkz-euclide-gui网页画图里了,我有时需要用原生的tikz画图也把那个打开一下,生成一个空的tikz代码,然后复制这一段进来。

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2024-12-13 20:35:32
abababa 发表于 2024-12-13 12:33
我现在也不知道这是什么了,这些都是以前我和maven讨论的时候加的一些参数 ...
对比了3种代码:
\node[label=A]at(0,0){};
\scriptsize
\node[label=A]at(0,0){};
[every label/.style={font=\scriptsize}]
\node[label=A]at(0,0){};
[label style/.style={font=\scriptsize}]
\node[label=A]at(0,0){};

发现[label style/.style={font=\scriptsize}]没有作用

418

Threads

1627

Posts

110K

Credits

Credits
11886

Show all posts

 Author| abababa Posted at 2024-12-13 20:59:38
hbghlyj 发表于 2024-12-13 20:35
对比了3种代码:
\node(0,0){A};
是不是只针对tkz-euclide画出来的图才有这个效果?可能是那里内置的一些配置。

3148

Threads

8489

Posts

610K

Credits

Credits
66148
QQ

Show all posts

hbghlyj Posted at 2024-12-13 21:25:22
abababa 发表于 2024-12-13 12:59
是不是只针对tkz-euclide画出来的图才有这个效果?可能是那里内置的一些配置。 ...
试了一下,仍然没有效果呢
Screenshot 2024-12-13 134111.png
  1. \documentclass{article}
  2. \usepackage{tkz-euclide}
  3. \begin{document}
  4. \begin{tikzpicture}
  5. \node[label=A]at(0,0){};
  6. \end{tikzpicture}%
  7. \begin{tikzpicture}[label style/.style={font=\scriptsize}]
  8. \node[label=A]at(0,0){};
  9. \end{tikzpicture}
  10. \end{document}
Copy the Code

418

Threads

1627

Posts

110K

Credits

Credits
11886

Show all posts

 Author| abababa Posted at 2024-12-14 09:03:47
hbghlyj 发表于 2024-12-13 21:25
试了一下,仍然没有效果呢
你没用tkz-euclide里的命令来做,用了就有区别了:
  1. \begin{tikzpicture}[scale=1,label style/.style={font=\scriptsize}]
  2. \tkzDefPoints{1/1/A,1/2/B}
  3. \tkzLabelPoints[color=blue](A)
  4. \node at (B){$B$};
  5. \end{tikzpicture}
Copy the Code

手机版Mobile version|Leisure Math Forum

2025-4-20 11:44 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list