import LSystem
import Test.HUnit
--8. arrowhead
arrowhead x= f x
where
f 0 = GrabPen red :#: Go 10
f (x+1)= g x :#: p :#: f x :#: p :#: g x
g 0= GrabPen blue :#: Go 10
g (x+1)=f x :#: n :#: g x :#: n :#: f x
n= Turn 60
p= Turn (-60)
--9. snowflake
snowflake x= f x :#: n :#: n :#: f x :#: n :#: n :#: f x :#: n :#: n
where
f 0=GrabPen red :#: Go 10
f (x+1)= f x :#: p :#: f x :#: n :#: n :#: f x :#: p :#: f x
n=Turn 60
p=Turn (-60)
--10. hilbert
hilbert x=l x
where
f 0=GrabPen green :#: Go 10
f x=GrabPen green :#: Go 10
l 0=GrabPen red :#: Go 10
--f 0 = Go 10
--f x = Go 10
--l 0 = Sit
l (x+1)= p :#: r x :#: f x :#: n :#: l x :#: f x :#: l x :#: n :#: f x :#: r x :#: p
r 0=GrabPen blue :#: Go 10
-- r 0= Sit
r (x+1)= n :#: l x :#: f x :#: p :#: r x :#: f x :#: r x :#: p :#: f x :#: l x :#: n
n=Turn 90
p=Turn (-90)
----------colors
yellow = Colour 255 255 0
orange = Colour 255 165 0
peano x=f x
where
f 0=GrabPen red :#: Go 10
f (x+1)= f x :#: p :#: g x :#: p :#: p :#: g x :#: n :#: f x :#: n :#: n :#: f x :#: f x :#: n :#: g x :#: p
g 0=GrabPen blue :#: Go 10
g (x+1)=n :#: f x :#: p :#: g x :#: g x :#: p :#: p :#: g x :#: p :#: f x :#: n :#: n :#: f x :#: n :#: g x
n=Turn 60
p=Turn (-60)
cross x = f x :#: n :#: f x :#: n :#: f x :#: n :#: f x :#: n
where
f 0=GrabPen red :#: Go 10
f (x+1)= f x :#: n :#: f x :#: p :#: f x :#: p :#: f x :#: f x :#: n :#: f x :#: n :#: f x :#: p :#: f x
n=Turn 90
p=Turn (-90)
branch x = g x
where
g 0=GrabPen blue :#: Go 10
g (x+1)= f x :#: n :#: Branch ( Branch (g x):#: p :#: g x ) :#: p :#: f x :#: Branch ( p :#: f x :#: g x):#: n :#: g x
f 0=GrabPen red :#: Go 10
f (x+1)= f x :#: f x
n=Turn 22.5
p=Turn (-22.5)
bush x = f x
where
f 0=GrabPen yellow :#: Go 10
f (x+1)= g x :#: n :#: Branch ( Branch (f x):#: p :#: f x ) :#: p :#: g x :#: Branch ( p :#: g x :#: f x):#: n :#: f x
g 0=GrabPen red :#: Go 10
g (x+1)= g x :#: g x
n=Turn 22.5
p=Turn (-22.5)
seg x= f x :#: p :#: f x :#: p :#: f x :#: p :#: f x
where
f 0=GrabPen orange:#: Go 10
f (x+1)= n :#: f x :#: p :#: f x :#: n :#: f x :#: n :#: f x :#: p :#: f x :#: p :#: f x :#: f x :#: n :#: f x :#: p :#: f x :#: p :#: f x :#: f x :#: p :#: f x :#: n :#: f x :#: n :#: f x :#: f x :#: p :#: f x :#: f x :#: n :#: f x :#: f x :#: p :#: f x :#: p :#: f x :#: n :#: f x :#: f x :#: n :#: f x :#: n :#: f x :#: p :#: f x :#: f x :#: n :#: f x :#: n :#: f x :#: p :#: f x :#: p :#: f x :#: n :#: f x :#: p
n=Turn 90
p=Turn (-90)
form::Command
form = (bush 5) :#: GrabPen black :#: Go 10 :#: (bush 5) :#: GrabPen black :#: Go 10 :#: (bush 5) :#: GrabPen black :#: Go 150 :#: (peano 3) :#: GrabPen black :#: Go 10 :#: (bush 5) :#: GrabPen black :#: Go 10 :#: (bush 5) :#: GrabPen black :#: Go 10 :#: (bush 5) :#: GrabPen black :#: Go 250
form1::Int->Command
form1 0 =Sit
form1 n = form :#: form1 (n-1)
f::Command
f = (cross 3) :#: Go 100 :#: (cross 3) :#: Go 100 :#: (cross 3) :#: Go 100
formp::Int->Command
formp 0 =Sit
formp n = f :#: formp (n-1)
showEntry :: IO ()
showEntry = display 0.1 ((seg 3) :#: GrabPen black :#: Go 10 :#: (form1 8):#: GrabPen Inkless :#: Go 3350 :#: Turn (90) :#: Go 1350 :#: Turn 90 :#: (formp 6))
{-
bushes :: Int -> Command
bushes m = join (replicate m ( GrabPen black :#: Go 10 :#: (bush 5) ))
showEntry1 :: IO ()
showEntry1 = display 0.01 ((seg 3) :#: GrabPen black :#: Go 10 :#: (bushes 3)
main = runTestTT (test [joinTests, splitTests, copyTests,
pentagonTests, polygonTests, spiralTests,
optimiseTests])
-}