# Demko, S., Hodges, L., and Naylor B
# Construction of Fractal Objects with Iterated Function Systems
# Computer Graphics 19, 3, July 1985, Pages 271-278
xn(x,y,r) = (r < 0.1) ? 0 : (r < 0.18) ? 0.2*x-0.26*y :\
            (r < 0.26) ? -0.15*x+0.28*y : (r < 1) ? 0.75*x+0.04*y : 0
yn(x,y,r) = (r < 0.1) ? 0.16*y : (r < 0.18) ? 0.23*x+0.22*y+1.6 :\
            (r < 0.26) ? 0.26*x+0.24*y+0.44 : (r < 1) ? -0.04*x+0.85*y+1.6 : 0

set samples 500000
set term pngc enh font "Arial,10" size 480,480
set out "IFS_fern.png"
unset key
unset border
unset tics
set xrange [-5:5]
set yrange [0:10]
xp = yp = xc = yc = 0.0
plot '+' u (r=rand(0), xc=xn(xp,yp,r), yc=yn(xp,yp,r), xc) : \
           (xp=xc,yp=yc,yc) w dots lc rgb "dark-green"

!display IFS_fern.png