Barnsley fern: Difference between revisions

→‎{{header|Perl}}: adding PARI/GP script
(added Delphi)
(→‎{{header|Perl}}: adding PARI/GP script)
Line 320:
}
}</lang>
 
=={{header|PARI/GP}}==
{{trans|zkl}}
{{Works with|PARI/GP|2.7.4 and above}}
[[File:BarnsleyFern.png|right|thumb|Output BarnsleyFern.png]]
 
<lang parigp>
\\ Barnsley fern fractal
\\ 6/17/16 aev
pBarnsleyFern(size,lim)={
my(X=List(),Y=X,x=y=xw=yw=0.0,r);
print(" *** Barnsley Fern, size=",size," lim=",lim);
plotinit(0); plotcolor(0,6); \\green
plotscale(0, -3,3, 0,10); plotmove(0, 0,0);
for(i=1, lim,
r=random(100);
if(r<=1, xw=0;yw=0.16*y,
if(r<=8, xw=0.2*x-0.26*y;yw=0.23*x+0.22*y+1.6,
if(r<=15, xw=-0.15*x+0.28*y;yw=0.26*x+0.24*y+0.44,
xw=0.85*x+0.04*y;yw=-0.04*x+0.85*y+1.6)));
x=xw;y=yw; listput(X,x); listput(Y,y);
);\\fend i
plotpoints(0,Vec(X),Vec(Y));
plotdraw([0,-3,-0]);
}
{\\ Executing:
pBarnsleyFern(530,100000); \\ BarnsleyFern.png
}
</lang>
{{Output}}
 
<pre>
> pBarnsleyFern(530,100000); \\ BarnsleyFern.png
*** Barnsley Fern, size=530 lim=100000
</pre>
 
=={{header|Perl}}==
Anonymous user