我正在尝试在乳胶中填充线条和弧之间的区域。下面是我使用的代码,它没有填满整个区域。我肯定有些地方我做得不对,我是这个平台的新手。有人能帮忙吗?这是我的代码和输出
\begin{tikzpicture}
\draw[name path=A](0.4,0)--(0.2,0)--(0.2,-0.3)--(0.8,-0.5) (-0.8,-0.5)-- (-0.2,-0.3)--(-0.2,0)--(-0.4,0);
\draw[name path=B](0.8,-0.5)--(0.3,-2)(-0.3,-2)--(-0.8,-0.5)-- (0.8,-0.5);
\draw[name path=C](0.6,-2)++(180:0.3) arc (0:-180:0.3);
%\draw[name path=D](-0.8,-0.5)--(0.8,-0.5);
\begin{pgfonlayer}{bg}
\fill [orange!90,
intersection segments={
of=A and B,
sequence={L2--R2}
}];
\fill [orange!90,
intersection segments={
of=B and C,
sequence={L2--R2}
}];
\end{pgfonlayer}
\end{tikzpicture}
答案1
如果期望的结果是
您可以使用:
\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw
(0.4,0)--(0.2,0)--(0.2,-0.3)--(0.8,-0.5)
(-0.8,-0.5)-- (-0.2,-0.3)--(-0.2,0)--(-0.4,0)
;
\draw[fill=orange!90]
(0.8,-0.5)--(0.3,-2)
arc (0:-180:0.3)
--(-0.8,-0.5)--cycle
;
\end{tikzpicture}
\end{document}
答案2
A元帖子另一种方法是,通过找到切点,稍微调整一下,使底部的曲线看起来整齐。我相信,你可以使用坐标tangent
系在 tikz 中做类似的事情。
\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
% set the various points
z4 = 190 up rotated 25;
z3 = 200 up rotated 5;
z2 = z3 shifted 30 up;
z1 = z2 shifted 20 left;
% now find the tangent point
path c, c';
c = fullcircle scaled 50 rotated 90;
c' = fullcircle scaled abs(z4) shifted 0.5 z4;
(t,t') = c intersectiontimes c';
path side, vessel;
side = z1--z2--z3--z4--subpath(t,4) of c;
vessel = side & reverse side reflectedabout(up,down);
level = 3.1;
fill subpath(0+level,length(vessel)-level) of vessel
-- cycle withcolor 1/2[red + 1/2 green, 15/16 white];
draw vessel withpen pencircle scaled 1;
endfig;
\end{mplibcode}
\end{document}
使用以下方式编译lualatex
(或者剥离 LaTeX 包装器并使用mpost
)