Chaos game: Difference between revisions

m
→‎{{header|Haskell}}: Added a dragon curve
m (→‎{{header|Perl 6}}: style tweak)
m (→‎{{header|Haskell}}: Added a dragon curve)
Line 202:
 
<lang haskell>-- the Sierpinsky`s triangle
triangle :: Transformations
triangle = [ (mid (0, 0), 1)
, (mid (1, 0), 1)
Line 209 ⟶ 208:
 
-- the Barnsley's fern
fern :: Transformations
fern = [(f1, 1), (f2, 85), (f3, 7), (f4, 7)]
where f1 (x,y) = (0, 0.16*y)
f2 (x,y) = (0.85*x + 0.04*y, -0.04*x + 0.85*y + 1.6)
f3 (x,y) = (0.2*x - 0.26*y, 0.23*x + 0.22*y + 1.6)
f4 (x,y) = (-0.15*x + 0.28*y, 0.26*x + 0.24*y + 0.44)</lang>
 
-- A dragon curve
dragon = [(f1, 1), (f2, 1)]
where f1 (x,y) = (0.5*x - 0.5*y, 0.5*x + 0.5*y)
f2 (x,y) = (-0.5*x + 0.5*y+1, -0.5*x - 0.5*y)</lang>
 
Drawing the result:
Anonymous user