-- INSTRUCTIONS -- run main for my main entry -- if im allowed to submit multiple pictures then also run colourSwirl and triSpiral -- Code by Nat Noordanus import LSystem spiral :: Distance -> Int -> Distance -> Angle -> Command spiral segment n step angle | n > 0 = Go segment :#: Turn angle :#: (spiral (segment-step) (n-1) step angle) | otherwise = Sit cspiral :: Pen -> Distance -> Int -> Distance -> Angle -> Command cspiral pen segment n step angle | n > 0 = GrabPen pen :#: Go segment :#: Turn angle :#: (cspiral (colourCycle pen) (segment-step) (n-1) step angle) | otherwise = Sit gradspiral :: Pen -> Pen -> Distance -> Int -> Distance -> Angle -> Command gradspiral pen1 pen2 segment n step angle | n > 0 = gradGo pen1 pen2 (segment/2) :#: gradGo pen2 pen1 (segment/2) :#: Turn angle :#: (gradspiral pen1 pen2 (segment-step) (n-1) step angle) | otherwise = Sit gradGo :: Pen -> Pen -> Float -> Command gradGo (Colour a b c) (Colour d e f) length = drawSegment (Colour a b c) (Colour ((d-a)/100) ((e-b)/100) ((f-c)/100)) (length/100) 100 where drawSegment col1 col2 l n | n > 0 = GrabPen col1 :#: Go l :#: drawSegment (addColour col1 col2) col2 l (n-1) | otherwise = Sit colourCycle :: Pen -> Pen colourCycle (Colour a b c ) | a == b, b==c = Colour (0.21) (0.2) (0.2) | a > b, a > c, a < 1 = Colour (a+0.05) b c | b > a, b > c, b < 1 = Colour a (b+0.1) c | c > a, c > b, c < 1 = Colour a b (c+0.1) | a >= 1 = Colour (0.2) (0.21) (0.2) | b >= 0.7 = Colour (0.2) (0.2) (0.21) | c >= 0.7 = Colour (0.21) (0.2) (0.2) addColour :: Pen -> Pen -> Pen addColour (Colour a b c) (Colour d e f) = (Colour (a+d) (b+e) (c+f)) pattern = display 0.5 (GrabPen Inkless :#: Go (400) :#: Turn 90 :#: Go (-500) :#: GrabPen blue :#: (spiral 1000 1000 1 (99))) colourPattern = display 0.5 (GrabPen Inkless :#: Go (400) :#: Turn 90 :#: Go (-500) :#: (cspiral blue 1000 1000 1 (99))) colourSwirl = display 1 (GrabPen Inkless :#: Go (400) :#: Turn 90 :#: Go (-500) :#: (cspiral blue 1000 2000 0.5 (99))) lotus = display 0.55 (GrabPen Inkless :#: Go (-250) :#: Turn 90 :#: Go (-490) :#: (cspiral blue 1000 1000 1 220)) triSpiral = display 0.5 (GrabPen Inkless :#: Go (400) :#: Turn 90 :#: Go (-500) :#: (cspiral blue 1000 2500 0.5 (11*11))) christmasTree = display 0.5 (GrabPen Inkless :#: Go (-200) :#: Turn 90 :#: Go (-550) :#: (gradspiral (Colour 0 0.8 0 ) (Colour 0 0.2 0) 1000 1000 1 220)) main = lotus