🔗Asymptote Gallery Tagged by “Picture” #86
đź”—fractales-fig001

Show fractales/fig0010.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Fractals
Tags : #Function (creating) | #Fractals | #Recursion | #Transform | #Picture
// From documentation of Asymptote size(250); real a=3; real b=4; real c=hypot(a,b); transform ta=shift(c,c)*rotate(-aCos(a/c))*scale(a/c)*shift(-c); transform tb=shift(0,c)*rotate(aCos(b/c))*scale(b/c); picture Pythagorean(int n) { picture pic; fill(pic,scale(c)*unitsquare,1/(n+1)*green+n/(n+1)*brown); if(n == 0) return pic; picture branch=Pythagorean(--n); add(pic,ta*branch); add(pic,tb*branch); return pic; } add(Pythagorean(12));
đź”—fractales-fig003

Show fractales/fig0030.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Fractals
Tags : #Fractals | #Recursion | #Transform | #Picture | #Function (creating)
// Barnsley's fern // Fougère de Barnsley size(5cm,0); real ab=85, ac=-5; real rc=.85, rb=-.31; path trk=(0,0)--(0,1); transform ta=shift(0,1)*rotate(ab)*scale(rb); transform tb=shift(0,1)*rotate(-ab)*scale(rb); transform tc=shift(0,1)*rotate(ac)*scale(rc); picture fern(int n) { picture opic; draw(opic,trk^^ta*trk^^tb*trk^^tc*trk); if (n==0) return opic; picture branch=fern(n-1); add(opic,branch); add(opic,ta*branch); add(opic,tb*branch); add(opic,tc*branch); return opic; } add(fern(6));
đź”—fractales-fig004

Show fractales/fig0040.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Fractals
Tags : #Fractals | #Transform | #Picture
// Barnsley's fern // Fougère de Barnsley size(10cm,0); real ab=72, ac=-7; real rc=0.85, rb=0.35; path trk=(0,0)--(0,1); transform ta=shift(0,1)*rotate(ab)*scale(rb); transform tb=shift(0,1)*rotate(-ab)*scale(rb); transform tc=shift(0,1)*rotate(ac)*scale(rc); transform td=shift(0,1)*rotate((ab+ac)/2)*scale(rb); transform te=shift(0,1)*rotate(-(ab+ac)/2)*scale(rb); picture pic; draw(pic,trk,red+.8green); //Construct a fern branch as atractor int nbit=7; for(int i=1; i<=nbit; ++i) { picture pict; add(pict,ta*pic); add(pict,tb*pic); add(pict,tc*pic); draw(pict,(0,0)--(0,1), (2*(i/nbit)^2)*bp+((1-i/nbit)*green+i/nbit*brown)); pic=pict; } //Use the fern branch to construct... a fern branch picture pict; add(pict,ta*pic); add(pict,tb*pic); pair x=(0,1); nbit=23; for(int i=1; i<=nbit; ++i) { add(shift(x)*rotate(ac*i)*scale(rc^i)*pict); draw(tc^i*((0,0)--(0,1)), 2*(1.5-i/nbit)^2*bp+brown); x=tc*x; } shipout(bbox(3mm, 2mm+black, FillDraw(paleyellow)));
đź”—fractales-fig005

Show fractales/fig0050.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Fractals
Tags : #Fractals | #Transform | #Picture
// Barnsley's fern // Fougère de Barnsley size(5cm,0); real ab=85, ac=-5; real rc=0.8, rb=0.3; path trk=(0,0)--(0,1); transform [] t; t[1] =shift(0,1)*rotate(ab)*scale(rb); t[2] =shift(0,1)*rotate(-ab)*scale(rb); t[3] =shift(0,1)*rotate(ac)*scale(rc); real sum=0; for(int i=0; i<100; ++i) sum+=(rc*cos(ac*pi/180))^i; t[4] =xscale(0.01)*yscale(1/sum); picture pic; draw(pic,trk); pair pt=(0,0); for(int i=0; i < 1000; ++i) { pt=t[ 1+floor((3.0*rand()/randMax)) ]*pt; } int nbt; for(int i=0; i < 200000; ++i) { nbt=1+floor((4.0*rand()/randMax)); pt=t[nbt]*pt; draw(pt); }
đź”—fractales-fig008

Show fractales/fig0080.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Fractals
Tags : #Fractals | #Loop/for/while | #Picture
size(10cm,0); real mandelbrot(pair c, real r, int count=100) { int i=0; pair z=c; do { ++i; z=z^2+c; } while (length(z) <= r && i<count); return (i<count) ? i/count : 0; } real r=4; real step=.01; real xmin=-2.25, xmax=.75; real ymin=-1.3, ymax=0; real x=xmin, y=ymin; int xloop=round((xmax-xmin)/step); int yloop=round((ymax-ymin)/step); pen p; path sq=scale(step)*unitsquare; for(int i=0; i < xloop; ++i) { for(int j=0; j < yloop; ++j) { p=mandelbrot((x,y),r,20)*red; filldraw(shift(x,y)*sq,p,p); y += step; } x += step; y=ymin; } add(reflect((0,0),(1,0))*currentpicture);
đź”—fractales-fig009

Show fractales/fig0090.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Fractals
Tags : #Fractals | #Recursion | #Transform | #Picture | #Array
size(10cm,0); real a=-1.5, b=2a/3; picture H(pen p=currentpen) { picture H; draw(H,(-a,0)--(a,0)^^(-a,-b)--(-a,b)^^(a,-b)--(a,b),p); return H; } transform sc=scale(0.5); transform[] t={identity(), shift(-a,b)*sc, shift(-a,-b)*sc, shift(a,b)*sc, shift(a,-b)*sc}; picture Hfractal(int n, pen p=currentpen) { picture pic; if(n == 0) return H(p); picture Ht=Hfractal(n-1,p); for (int i=0; i < 5; ++i) add(pic,t[i]*Ht); return pic; } add(Hfractal(4, bp+0.5*red));
đź”—fractales-fig010

Show fractales/fig0100.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Fractals
Tags : #Fractals | #Recursion | #Transform | #Picture | #Array
size(10cm,0); real a=-1.5, b=2a/3; path[] H=(-a,0)--(a,0)^^(-a,-b)--(-a,b)^^(a,-b)--(a,b); transform sc=scale(0.5); transform[] t={shift(-a,b)*sc, shift(-a,-b)*sc, shift(a,b)*sc, shift(a,-b)*sc}; void Hfractal(path[] g, int n, pen[] p=new pen[]{currentpen}) { p.cyclic=true; if(n == 0) draw(H,p[0]); else { for (int i=0; i < 4; ++i) { draw(t[i]*g,p[n]); Hfractal(t[i]*g,n-1,p); } } } Hfractal(H, 5, new pen[] {0.8*red, 0.8*green, 0.8*blue, black, blue+red});
đź”—generalities-fig089

Show generalities/fig0890.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 2D | Generalities
Tags : #Basis | #Deferred drawing | #Arrows/Bars | #Labelmargin | #Margin | #Picture
//From documentation of Asymptote size(6cm, 0); void distance(picture pic=currentpicture, pair A, pair B, Label L="", real n=0, pen p=currentpen) { real d=3mm; guide g=A--B; transform T=shift(-n*d*unit(B-A)*I); pic.add(new void(frame f, transform t) { picture opic; guide G=T*t*g; draw(opic, G, p, Arrows(NoFill), Bars, PenMargins); label(opic, L, midpoint(G), UnFill(1)); add(f, opic.fit()); }); pic.addBox(min(g), max(g), T*min(p), T*max(p)); } pair A=(0, 0), B=(3, 3); dot(A); dot(B); distance(A, B, Label("$\ell$", Rotate(dir(A--B))), 1);
đź”—generalities-fig101

Show generalities/fig1010.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 2D | Generalities
Tags : #Basis | #Circle | #Picture | #Transform/scale/shift/rotate | #Array
size(8cm,0); picture pic; pen [] P={.8red,.7green,blue+.5grey,yellow+.6grey}; fill(scale(10)*unitcircle,.2blue); for (int i = 0; i <= 3; ++i) draw(pic, arc((0,0),10,i*90,(i+1)*90), P[i]); for (real i = 1; i <= 10; i+=.05) add(rotate(90*i)*scale(1/i)*pic);
đź”—generalities-fig108

Show generalities/fig1090.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 2D | Generalities
Tags : #Basis | #Fill/Unfill | #Picture
size(6cm,0); pair A=0, B=(1,0), C=(.7,1); void fillangle(picture pic=currentpicture, pair O=0, pair A, pair B, real radius=10, pen p=grey) { picture tpic; int n=sgn(radius); real a1=degrees(shift(-O)*A,false); real a2=degrees(shift(-O)*B,false); fill(tpic,(0,0)--arc((0,0), -radius, max(a1,a2), min(a1,a2),true)--cycle, p=p); add(pic,tpic,O); } draw(A--B--C--cycle); real r1=15, r2=20; fillangle(A,B,C,r1,.8red); fillangle(A,B,C,-r2); fillangle(B,A,C,r1,.8red); fillangle(B,A,C,-r2); fillangle(C,B,A,r1,.8red); fillangle(C,B,A,-r2);
đź”—generalities-fig196

Show generalities/fig1980.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 2D | Generalities
Tags : #Label | #Object | #Picture
void enclose(picture pic=currentpicture, envelope e, Label[] L=new Label[], real xmargin=0, real ymargin=xmargin, pen p=currentpen, filltype filltype=NoFill, bool above=true) { real H; real[] h; pic.add(new void (frame f, transform t) { frame[] d=new frame[]; for (int i=0; i<L.length; ++i) { d[i]=newframe; Label LL=L[i].copy(); add(d[i],t,LL); add(f,d[i]); h[i]=ypart(max(d[i])-min(d[i])); if(H < h[i]) H=h[i]; } for (int i=0; i<L.length; ++i) { real emy=(H-h[i])/2; e(f,d[i],xmargin,ymargin+emy,p,filltype,above); } }); } void box(picture pic=currentpicture, Label[] L=new Label[], real xmargin=0, real ymargin=xmargin, pen p=currentpen, filltype filltype=NoFill, bool above=true) { enclose(pic,box,L,xmargin,ymargin,p,filltype,above); } box(new Label[] { Label("\begin{minipage}{3cm}Some text some text some text.\end{minipage}",(2.2cm,0)), Label("Hello.",0), Label("\begin{minipage}{3cm}Some text some text some text some text some text some text some text.\end{minipage}",(5.4cm,0)), Label("Bye.\rule{0pt}{1.5cm}",(1cm,-3cm)) });
đź”—graph-fig034

Show graph/fig0350.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 2D | Graph.asy
Tags : #Graph | #Function (drawing) | #Align | #Picture | #Transform/scale/shift/rotate/projection
// From Asymptote's FAQ import graph; real width=15cm; real aspect=0.3; picture pic1,pic2; size(pic1,width,aspect*width,IgnoreAspect); size(pic2,width,aspect*width,IgnoreAspect); scale(pic1,false); scale(pic2,false); real xmin1=6; real xmax1=9; real xmin2=8; real xmax2=16; real a1=1; real a2=0.001; real f1(real x) {return a1*sin(x/2*pi);} real f2(real x) {return a2*sin(x/4*pi);} draw(pic1,graph(pic1,f1,xmin1,xmax1)); draw(pic2,graph(pic2,f2,xmin2,xmax2)); xaxis(pic1,Bottom,LeftTicks()); yaxis(pic1,"$f_1(x)$",Left,RightTicks); xaxis(pic2,Bottom,LeftTicks(Step=4)); yaxis(pic2,"$f_2(x)$",Left,RightTicks); yequals(pic1,0,Dotted); yequals(pic2,0,Dotted); pair min1=point(pic1,SW); pair max1=point(pic1,NE); pair min2=point(pic2,SW); pair max2=point(pic2,NE); real scale=(max1.x-min1.x)/(max2.x-min2.x); real shift=min1.x/scale-min2.x; transform t1 = pic1.calculateTransform(); transform t2 = pic2.calculateTransform(); transform T=xscale(scale*t1.xx)*yscale(t2.yy); add(pic1.fit()); real height=truepoint(N).y-truepoint(S).y; add(shift(0,-height)*(shift(shift)*pic2).fit(T));
đź”—tiling-fig001

Show tiling/fig0010.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Tiling | #Function (creating) | #Picture
size(10cm,0); picture pavehexagonal(int depth=1) { picture opic; path hexa=polygon(6); pair center; real a,ap,r,rp,r_d=180/pi; for(int j=0; j<depth; ++j) { for (int i=1; i<=6; ++i) { a=i*60-30; r=j*sqrt(3); center=r*(rotate(a)*(1,0)); filldraw(opic, shift(center)*hexa, j/depth*.8red+(1-j/depth)*.8*blue); //Uncomment to see centers of hexagons dot(opic, shift(center)*midpoint(point(hexa,0)--point(hexa,3))); //Uncomment to see circles passing by centers //draw(opic, scale(r)*unitcircle, j/depth*red+(1-j/depth)*blue); rp=r; ap=0; for (real k=0; k<j-1; ++k) { r=sqrt((1.5*(j-1 - k))^2 + 3/4*(j+1 + k)^2); ap+=r_d*acos((rp^2 + r^2 - 3)/(2*r*rp)); center=r*(rotate(a + ap)*(1,0)); filldraw(opic, shift(center)*hexa, j/depth*.8*red+(1-j/depth)*.8*blue); //Uncomment to see the centers of hexagons //dot(opic, shift(center)*midpoint(point(hexa,0)--point(hexa,3))); rp=r; //Uncomment to see circles passing by centers //draw(opic, scale(r)*unitcircle, j/depth*red+(1-j/depth)*blue); } } } return opic; } add(pavehexagonal(7));
đź”—tiling-fig003

Show tiling/fig0030.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Surveys | Tiling
Tags : #Path | #Picture | #Tiling
size(10cm,0); transform r60=rotate(60); pair A=(sqrt(3)/2,-.5); pair B=r60*A, C=r60*B, D=r60*C, E=r60*D, F=r60*E; path AB=A{dir(90)}..(.6,.5)..B{dir(0)}; path DE=shift(E-A)*reverse(AB); path BC=B{dir(45)}..(.75,.7){dir(150)}..{dir(135)}(.65,.75){dir(70)}..(.5,1.25)..C{dir(255)}; path EF=shift(F-B)*reverse(BC); path CD=C{dir(255)}..(-.4,.5){dir(200)}..D{dir(160)}; path FA=shift(A-C)*reverse(CD); draw(A--B--C--D--E--F--cycle,linewidth(2pt)); draw(AB,2pt+.8red); draw(DE,2pt+.8red); draw(BC,2pt+.8blue); draw(EF,2pt+.8blue); draw(CD,2pt+.8green); draw(FA,2pt+.8green); picture hexa; picture eye; filldraw(hexa,AB--BC--CD--DE--EF--FA--cycle,black,white); filldraw(eye,rotate(5)*xscale(.4)*unitcircle,white); filldraw(hexa,subpath(AB,1,2)--subpath(BC,0,2){dir(225)}..{dir(245)}cycle,.1red+yellow,white); draw(hexa,point(BC,0.1){dir(115)}.. (.8,.55) ..(.6,.65){dir(180)},yellow+grey); filldraw(eye,rotate(5)*xscale(.4)*unitcircle,white); fill(eye,rotate(5)*shift(0,-.1)*xscale(.25)*scale(.5)*unitcircle); add(hexa,shift(.6,.9)*scale(.1)*eye); add(shift(3,0)*hexa);
đź”—various-fig008

Show various/fig0405.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Miscellaneous
Tags : #Transform | #Picture
// PDF version of this picture: /home/pi/code/pi/asymptote/asymptote-exemples-builder/build/asy/various/fig0405.pdf import labelpath; size(17cm,0); usepackage("mathrsfs, amsfonts,amsmath,amssymb"); picture pic, pic1, pic2, pic3; real u=1, Y=pi+0.2; path cle=scale(u)*unitcircle; path arcg=arc((0,0),1.5*u,115,155); void addtick(picture pic=currentpicture, Label L, pair z, pair dir=E, pen p=currentpen) { transform R=rotate(degrees(dir)); real width=1.5mm; Label L=L.copy(); L.position(z); L.align(NoAlign,E); L.align.dir=R*L.align.dir*1.3*width/mm; L.p(p); pic.add(new void(frame f, transform t) { path g=(-width,0)--(width,0); picture opic; draw(opic,shift(t*z)*R*g,p); add(f,opic.fit()); }); add(pic,L); } path roll(picture pic=currentpicture, real x, int nb=50) { real stp=x/(nb-1); return operator --(... sequence(new guide(int t){ real tt=t*stp; return shift(expi(tt))*((x-tt)*(-sin(tt),cos(tt))); },nb)); } labelpath("\tiny Sens direct",reverse(arcg)); draw(arcg, Arrow()); draw(Label("$\mathscr{C}$",Relative(0.625)), cle,bp+grey); dot("$O$", (0,0), S); dot("$0$", point(cle,0)); dot("$I$", point(cle,0), 2*W); dot("$J$", point(cle,1), 2*S); dot("$K$", point(cle,2), 2*W); dot("$L$", point(cle,3), 2*N); draw("$1$",(0,0)--point(cle,2),Arrows); pic.add(currentpicture);// Save the common picture. // Starting picture 1 pair yM=(u,Y*u), ym=(u,-Y*u); draw(ym--yM, linewidth(bp), Arrow(TeXHead)); arrow("\underline{Axe des r\'eels}",(u,-0.75*Y*u),W,1cm); real x=2.2, y=-1.25; addtick(Label("$1$", align=E),(u,1)); addtick(Label("$2$", align=E),(u,2)); addtick(Label("$-1$", align=E),(u,-1)); addtick(Label("$x$", align=E),(u,x)); addtick(Label("$y$", align=E),(u,y)); pic1.add(currentpicture); erase(); // Starting picture 2 add(pic); real t=x+0.1; draw((u,0)--yM, bp+grey, Arrow(TeXHead)); path tg=arc((0,0),u,0,degrees(t)); draw(tg,linewidth(bp)); addtick(Label("$1$", align=E),u*(cos(1),sin(1)),dir(degrees(1.0))); addtick(Label("$1$", align=E),(u,1), grey); addtick(Label("$2$", align=E),(u,2),grey); addtick(Label("$\frac{\pi}{2}$", align=E),(u,pi/2),grey); addtick(Label("$\pi$", align=E),(u,pi),grey); addtick(Label("$-1$", align=E),(u,-1)); addtick(Label("$x$", align=E),(u,x), grey); addtick(Label("$x$", align=E),u*(cos(x),sin(x)),dir(degrees(x))); addtick(Label("$y$", align=E),(u,-x)); dot("$M$", u*expi(x), -2*u*expi(x)); draw(Label("+",Relative(0.5)), roll(x), dotted, Arrow(Relative(0.5))); draw(roll(1), dotted); draw(Label("+",Relative(0.5)), roll(pi/2), dotted, Arrow(Relative(0.5))); draw(Label("+",Relative(0.5)), roll(pi,100), dotted, Arrow(Relative(0.5))); path g=u*expi(t)--shift(u*expi(t))*((Y-t)*u*expi(pi/2+t)); draw(g,linewidth(bp), Arrow(TeXHead)); addtick(Label("$\pi$", align=E),arcpoint(g,(pi-t)*u),expi(t)); pic3.add(currentpicture); draw(ym--(u,0), linewidth(bp)); pic2.add(currentpicture); erase(); // Starting picture 3 draw(ym--(u,0), linewidth(bp)+grey); path tg=arc((0,0),u,0,degrees(-t)); draw(tg,linewidth(bp)); addtick(Label("$-1$", align=E),u*(cos(-1),sin(-1)),dir(degrees(-1.0))); addtick(Label("$-1$", align=E),(u,-1), grey); addtick(Label("$-2$", align=E),(u,-2),grey); addtick(Label("$-\frac{\pi}{2}$", align=E),(u,-pi/2),grey); addtick(Label("$-\pi$", align=E),(u,-pi),grey); dot("$N$", u*expi(-x), -2*u*expi(-x)); g=roll(-x); draw(Label("$-$",align=2*I*dir(g,0.5),Relative(0.5)), g, dotted, Arrow(NoFill,Relative(0.5))); g=roll(-1); draw(g, dotted); g=roll(-pi/2); draw(Label("$-$",align=2*I*dir(g,0.5),Relative(0.5)), g, dotted, Arrow(NoFill,Relative(0.5))); g=roll(-pi,100); draw(Label("$-$",align=2*I*dir(g,0.5),Relative(0.5)), g, dotted, Arrow(NoFill,Relative(0.5))); g=u*expi(-t)--shift(u*expi(-t))*((Y-t)*u*expi(-pi/2-t)); draw(g, linewidth(bp), Arrow(TeXHead)); addtick(Label("$-\pi$", align=E),arcpoint(g,(pi-t)*u),expi(-t)); //////////////////////////////////////////////////////////// pic3.add(currentpicture); erase(); add(pic1); add(shift(4*u,0)*pic2); add(shift(8*u,0)*pic3); shipout(format="pdf");
đź”—various-fig009

Show various/fig0410.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Miscellaneous
Tags : #Transform | #Picture
size(10cm); path cle=unitcircle; path roll(picture pic=currentpicture, real x, int nb=50) { real stp=x/(nb-1); return operator --(... sequence(new guide(int t){ real tt=t*stp; return shift(expi(tt))*((x-tt)*(-sin(tt),cos(tt))); },nb)); } real y=4*pi; pair yM=(1,y), ym=(1,-y); int nb=100; real stp=2*y/nb; path[] g; for (int i=1; i <= nb; ++i) { real t=-y+i*stp; g.push(roll(-y+i*stp/2,50+round(20*i*stp))--reverse(roll(y-i*stp/2,50+round(20*i*stp)))--cycle); } pen p1=blue, p2=0.9*red; fill(g,p1); fill(g,fillrule(1)+p2); unfill(cle); draw(cle,white); shipout(rotate(-90)*bbox(Fill(lightyellow)));