
\documentclass[border=10pt,pstricks,12pt]{standalone}
\begin{document}
\begin{pspicture}[showgrid](0,0)(3,3)
\pscircle*[linecolor=gray!20](1.5,1.5){1.5}
\pscircle[fillstyle=crosshatch*](1,2){1}
\pscircle[hatchcolor=gray,hatchsep=5pt,hatchwidth=.5pt,fillstyle=dots*](2,1){1}
\end{pspicture}
\end{document}
TikZ 有名為 的選項crosshatch dots
,Asymptote 與 TikZ 相同,hatch(1.5mm,dotted+...)
。代表著dotted in line
正如我所看到的,輸出圖像不是很好!那麼,我該如何dotted in line
在 PSTricks 中加入 vlines、hlines、crosshatch...?
我用 Asymptote 畫這張圖,但出現以下錯誤:
// asy -f pdf <name>.asy
import math;
import patterns;
unitsize(1cm);
defaultpen(1);
pair C1=(-3,0),C2=(2.5,0);
real r=4;
path EllipseA=scale(.75,.55)*circle(C1,r);
path EllipseB=scale(.5,.35)*circle(C2,r);
add("fillA",hatch(1.5mm,red));
add("AinterB",crosshatch(2mm,green));
add("fillB",hatch(1.5mm,dotted+blue+1.5bp));//
fill(EllipseA,pattern("fillA"));
fill(EllipseB,pattern("fillB"));
picture AinterB;
fill(AinterB,EllipseA,white);
fill(AinterB,EllipseA,pattern("AinterB"));
clip(AinterB,EllipseB);
add(AinterB);
draw(EllipseA^^EllipseB);
label("$C$",C1,dir(180),UnFill);
label("$D$",C2,UnFill);
label("$E$",(0,0),UnFill);
pair A=point(EllipseA,1.25),B=point(EllipseB,.5);
label("$A$",A,6N);
label("$B$",shift(.2,0)*B,6N);
label("$G$",(0,2),9N); // dot((0,1));
draw(A--shift(0,.6)*A);
draw(B--shift(.2,.7)*B);
draw(shift(-2.5,.75)*(0,1)--shift(-.5,2)*(0,1));
draw(shift(.2,0)*(0,1)--shift(0,2)*(0,1));
draw(shift(1.5,0)*(0,1)--shift(.5,2)*(0,1));
add(shift(-6,-3)*grid(10,7,1bp+dotted));
shipout(bbox(5mm,white));
看add("fillB",hatch(1.5mm,dotted+blue+1.5bp));//
,如果我用 1.2 替換 1.5mm,我會得到相同的輸出;如果我用 1.75mm 或 2mm 取代 1.5mm,我的真實輸出如下:
那麼,為什麼它們不同呢?這是 Asymptote 中的函數或...
答案1
關於 Asymptote 的奇怪行為
Asymptote 似乎有一個錯誤。我認為在某些條件hatch
和的參數之間存在週期性問題dotted
。其行為是剪切一條虛線,然後透過平鋪和剪切來添加圖案。但我不知道為什麼簡單的模式不會有這樣的問題line
。這是一個解決方法。定義一個像 dotted
pen 一樣的新筆就足夠了,但增加一個offset
:pen mdotted=linetype(new real[] {0,4},offset=.5);
import math;
import patterns;
unitsize(1cm);
defaultpen(1);
pair C1=(-3,0),C2=(2.5,0);
real r=4;
path EllipseA=scale(.75,.55)*circle(C1,r);
path EllipseB=scale(.5,.35)*circle(C2,r);
add("fillA",hatch(1.5mm,red));
add("AinterB",crosshatch(2mm,green));
pen mdotted=linetype(new real[] {0,4},offset=.5);
add("fillB",hatch(1.5mm,mdotted+blue+1.5bp));//
fill(EllipseA,pattern("fillA"));
fill(EllipseB,pattern("fillB"));
picture AinterB;
fill(AinterB,EllipseA,white);
fill(AinterB,EllipseA,pattern("AinterB"));
clip(AinterB,EllipseB);
add(AinterB);
draw(EllipseA^^EllipseB);
label("$C$",C1,dir(180),UnFill);
label("$D$",C2,UnFill);
label("$E$",(0,0),UnFill);
pair A=point(EllipseA,1.25),B=point(EllipseB,.5);
label("$A$",A,6N);
label("$B$",shift(.2,0)*B,6N);
label("$G$",(0,2),9N); // dot((0,1));
draw(A--shift(0,.6)*A);
draw(B--shift(.2,.7)*B);
draw(shift(-2.5,.75)*(0,1)--shift(-.5,2)*(0,1));
draw(shift(.2,0)*(0,1)--shift(0,2)*(0,1));
draw(shift(1.5,0)*(0,1)--shift(.5,2)*(0,1));
add(shift(-6,-3)*grid(10,7,1bp+dotted));
shipout(bbox(5mm,white));
和結果
我添加一個問題https://github.com/vectorgraphics/asymptote/issues/133
答案2
要在 PostScript 填滿圖案中使用點線筆,需要停用 Asymptote 對筆寬度及其線長調整的自動縮放:
import patterns;
unitsize(1cm);
pen dotted=linetype(new real[] {0,4},offset=1,scale=false,adjust=false);
add("fillA",hatch(1.5mm,red+1.5bp+opacity(0.5)));
add("fillB",hatch(1.5mm,blue+1.5bp+dotted));
fill(unitcircle,pattern("fillA"));
fill(unitcircle,pattern("fillB"));