# How to draw this pattern in PSTricks and its equivalent in Asymptote?

\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 has option named crosshatch dots, Asymptote has the same as TikZ, hatch(1.5mm,dotted+...). It means that dotted in line

As I see, the output image is not very good! So, how can I do to add dotted in line for vlines,hlines,crosshatch,... in PSTricks?

I am drawing this picture with Asymptote but I have the mistake as follow:

// 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);

fill(EllipseA,pattern("fillA"));
fill(EllipseB,pattern("fillB"));

picture AinterB;
fill(AinterB,EllipseA,white);
fill(AinterB,EllipseA,pattern("AinterB"));
clip(AinterB,EllipseB);

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));

shipout(bbox(5mm,white));


See add("fillB",hatch(1.5mm,dotted+blue+1.5bp));//, if I replace 1.5mm by 1.2, I get the same output; if I replace 1.5mm by 1.75mm or 2mm, I have the true output as follow:

So, why are they different? It is the function in Asymptote or ...

About the strange behavior of Asymptote

It seems that there is a bug with Asymptote. I think it is a periodicity problem under some conditions between the parameter of hatch and dotted. The behavior is to clip a dotted line and then by tiling and clipping to add the pattern. But I do not know why such a problem does not occur with simple line pattern. Here a workaround. It is sufficient to define a new pen like dotted pen but with adding an 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);

pen mdotted=linetype(new real[] {0,4},offset=.5);

fill(EllipseA,pattern("fillA"));
fill(EllipseB,pattern("fillB"));

picture AinterB;
fill(AinterB,EllipseA,white);
fill(AinterB,EllipseA,pattern("AinterB"));
clip(AinterB,EllipseB);

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));

shipout(bbox(5mm,white));


and the result

• While waiting for ..., your answer is accepted. Asymptote is my main problem. Thanks. – user197952 Dec 12 '19 at 12:55
• @justonly : thanks for finding this bug – O.G. Dec 12 '19 at 14:42

To use a dotted pen in a PostScript fill pattern, one needs to disable Asymptote's automatic scaling to the pen width and its line length adjustment:

import patterns;
unitsize(1cm);


It looks like a problem with your viewer. Do you view the dvi output?
• Yes, it looks like a problem with my TexStudio. I run it by TexStudio (latex-dvips-ps2pdf -dNOSAFER <name>.ps <name>.pdf) and the output of it as displayed. However, the pdf file is no problem. Thanks. – user197952 Dec 10 '19 at 3:19
• For Windows you should use Sumatra PDF for the external viewer. It is much more faster than Adobe – user187802 Dec 10 '19 at 9:45