Closed justonlyasy closed 3 years ago
I'll look into it. Don't forget the \ on \cos.
Another example of this, from https://asymptote.sourceforge.io/gallery/xsin1x.asy.
If the center is (0,0)
, no problem !? (as I see).
import graph;
size(15cm);
real f(real x) {return (x != 0.0) ? x * sin(1.0 / x) : 0.0;}
pair F(real x) {return (x,f(x));}
xaxis("$x$",red,Arrow);
yaxis("$y$",red,Arrow);
draw(graph(f,-1.2/pi,1.2/pi,1000));
label("$x\sin\frac{1}{x}$",F(1.1/pi),NW);
label("$0.15$",(0,.15),dir(180));
label("$-0.15$",(0,-.15),dir(180));
label("$0.15$",(.15,0),dir(-90));
label("$-0.15$",(-.15,0),dir(-90));
label("$0.3$",(.3,0),dir(-90));
label("$-0.3$",(-.3,0),dir(-90));
frame myframe=currentpicture.fit();
picture pic1,pic2;
size(pic1,15cm);
size(pic2,15cm);
path myclippath1 = box(-(0.02,0.02),(0.02,0.02));
path myclippath2 = circle((0.03,0.02),0.022);
draw(myclippath1,green);
draw(myclippath2,green);
path bigclippath1 = scale(4) * myclippath1;
path bigclippath2 = scale(4) * myclippath2;
add(pic1,scale(4) * myframe);
add(pic2,scale(4) * myframe);
layer(pic1);
layer(pic2);
clip(pic1,bigclippath1);
draw(pic1,bigclippath1,red);
clip(pic2,bigclippath2);
draw(pic2,bigclippath2,red);
transform t1=shift(-0.1,0.2);
transform t2=shift(0.1,0.2);
add(t1*pic1);
add(t2*pic2);
pair A=point(t1*pic1,dir(-60));
draw(Label("text",LeftSide,Rotate(dir(A--(min(myclippath1).x,max(myclippath1).y)))),
A--(min(myclippath1).x,max(myclippath1).y),blue,BeginArrow);
pair B=point(t2*pic2,dir(-120));
draw(Label("text",LeftSide,Rotate(dir(reverse(B--max(myclippath2))))),
B--max(myclippath2),blue,BeginArrow);
transform t2=shift(0.1,0.2);
is different with transform t2=shift(0.2,0.2);
If you use the deferred drawing technique illustrated in xsin1x.asy, you shouldn't have problems with the picture resizing like this. See the first article here:
I am still not familiar with the deferred drawing technique, so you can please post an illustration about the first example using this technique. Actually, I have asked two questions related to this problem,
clip
.Additional, the example in this question is inspired from this (he also uses clip
, however, there is a problem about this code) and this (Charles Staats also uses clip
).
There are many examples in O.G.'s answers, see here: What does the align
argument do in this Asymptote code? - TeX - LaTeX Stack Exchange
Test code, at http://asymptote.ualberta.ca/
You can see the difference between
transform t=shift(-3,1);
andtransform t=shift(-2,1);
. How can I use anytransform
but preserving contents of the clip picture?