问题描述
我正在尝试在 PSTricks 中绘制某种带有月亮镰刀的图画,但我无法将圆段连接在一起。
梅威瑟:
\documentclass[pstricks]{standalone}
\definecolor{ctcolorblack}{gray}{0}
\definecolor{ctcolorgray}{gray}{.5}
\definecolor{ctcolormain}{RGB}{0,150,255}
\begin{document}
\psset
{
unit=0.001,
linewidth=0.1pt,
}
\begin{pspicture}(18000,5000)
%% SICKLE
\pscustom[
linecolor=ctcolorgray,
linewidth=1.0pt,
fillstyle = solid,
fillcolor = white
]{
\psarc(2100,2100){1250}{22.03}{203.58}
\psarc(2145,1600){1000}{75.39}{-203.56}
}
\end{pspicture}
\end{document}
答案1
纯粹为了比较,你可以用有用的buildcycle
宏来做到这一点元帖子。这是 MP 中的版本,(没有工程尺寸注释)。
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);
path c[];
c1 = fullcircle scaled 2500 shifted (2100, 2100);
c2 = fullcircle scaled 2000 shifted (2145, 1600);
c3 = fullcircle scaled 1500 shifted (2615, 1850);
c4 = fullcircle scaled 1000 shifted (3085, 2100);
path sickle;
sickle = buildcycle(c1, c2, c3, c4);
fill sickle withcolor 15/16[blue, white];
draw sickle;
endfig;
\end{mplibcode}
\end{document}
这包含在中luamplib
,因此您应该使用它来编译它lualatex
或者使其适应普通的 Metapost。
MP 中默认的尺寸单位是 Postscript 点,因此给定的尺寸下,该图形的对角线长度为 3225 pt ≈ 113.7 cm,因此您可能需要将其缩小一点。一种方法是添加以下行:
sickle := sickle scaled 1/4;
在该buildcycle
行后面。这样,该图形就可以很好地显示在 A4 纸上。
答案2
对于 PSTricks,存在一个pst-intersect
我认为在这里有用的包,尽管这种方法需要相当多的步骤:
\documentclass[border=10pt]{standalone}
\usepackage{pst-intersect}
\definecolor{ctcolorgray}{gray}{.75}
\begin{document}
\psset{
unit=0.001,
linewidth=0.1pt,
}
\begin{pspicture}(5000,5000)
\pssavepath[linestyle=none]{c1}{\pscircle(2100,2100){1250}}
\pssavepath[linestyle=none]{c2}{\pscircle(2145,1600){1000}}
\pssavepath[linestyle=none]{c3}{\pscircle(2615,1850){750}}
\pssavepath[linestyle=none]{c4}{\pscircle(3085,2100){500}}
% reverse largest circle to clockwise
\pssavepath[linestyle=none]{s1}{
\pstracecurve[tstart=4, tstop=0]{c1}
}
% get intersections of largest circle reversed and second largest circle
\psintersect[name=i1]{s1}{c2}
% save arc of largest circle segment plus arc of second largest segment
\pssavepath[linestyle=none]{s2}{
\pstracecurve[istart=1, istop=2]{i1}{s1}
\pstracecurve[istart=0, istop=1]{i1}{c2}
}
% get intersections of above path with third largest circle
\psintersect[name=i2]{s2}{c3}
% save path ...
\pssavepath[linestyle=none]{s3}{
\pstracecurve[istart=0, istop=1]{i2}{s2}
\pstracecurve[istart=1, istop=2]{i2}{c3}
\pstracecurve[istart=2, istop=3]{i2}{s2}
}
% and so on ...
\psintersect[name=i3]{s3}{c4}
% ... until we get the complete path which we can draw and fill
\pscustom[fillstyle=solid, fillcolor=ctcolorgray]{
\pstracecurve[istart=0, istop=1]{i3}{s3}
\pstracecurve[istart=1, istop=2]{i3}{c4}
\pstracecurve[istart=2, istop=3]{i3}{s3}
}
\end{pspicture}
\end{document}
类似的解决方案使用fillbetween
使用Ti 提供的库的钾Z/PGF:
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{fillbetween}
\begin{document}
\begin{tikzpicture}[x=0.01, y=0.01, line width=0.1pt, fill=gray!10]
\path[name path=c1] (2100,2100) circle (1250);
\path[name path=c2] (2145,1600) circle (1000);
\path[name path=c3] (2615,1850) circle (750);
\path[name path=c4] (3085,2100) circle (500);
\path[name path=s12, intersection segments={of=c1 and c2, sequence={L1 -- R1[reverse]}}];
\path[name path=s123, intersection segments={of=s12 and c3, sequence={L1 -- R1[reverse]}}];
\filldraw[intersection segments={of=s123 and c4, sequence={L2 -- R2[reverse]}}];
\end{tikzpicture}
\end{document}