-- | Postscript renderer for 'LSystem's.
module LSystem.Render.PS where

import Graphics.PS {- hps -}

import LSystem.LSystem
import LSystem.Turtle

-- | Given initial 'ta', 'ls' and 'lls' values render /i/ steps of an
-- 'LSystem'.
renderL :: (LSystem,Double,Double) -> Int -> Double -> [Ln R]
renderL (l,ta',lls') i ll' =
    let a = Turtle (radians ta') 1 pt_origin (pi / 2) ll' lls' []
    in render [] (\ll'' p1 p2 -> Ln p1 p2 : ll'') (expand l i) a

-- | Draw output of 'renderL' normalised, scaled to /m/ and translated
-- by /o/.
draw :: R -> R -> [Ln R] -> Image
draw o m l =
    let g = greyGS 0.5
        p = renderLines' (lns_normalise m l)
    in translate o o (Stroke g p)