Bump version number for hackage upload
[L-seed.git] / src / renderAsPNG.hs
1 import Lseed.Data
2 import Lseed.Data.Functions
3 import Lseed.Grammar.Parse
4 import Lseed.Constants
5 import Lseed.Mainloop
6 import Control.Monad
7 import Debug.Trace
8 import System.Environment
9 import System.Time
10 import System.Random
11 import Lseed.Renderer.Cairo
12 import Data.Maybe
13 import Graphics.Rendering.Cairo
14
15 main = do
16         args <- getArgs
17         let name = fromMaybe "Some Plant" $ listToMaybe args
18
19         file <- getContents
20         case parseGrammar name file of
21          Left _ -> do 
22                 let (w,h) = (300,300)
23                 withImageSurface FormatRGB24 w h $ \sur -> do
24                         renderWith sur $ do
25                                 setSourceRGB 1 1 1
26                                 paint
27
28                                 translate 0 (0.5* fromIntegral h)
29                                 setFontSize (0.1* fromIntegral h)
30                                 setSourceRGB 0 0 0
31                                 showText "Syntax Error"
32                         surfaceWriteToPNG sur "/dev/fd/1"
33          Right genome -> do
34                 let garden = [Planted 0.5 0 name genome inititalPlant]
35                 obs <- pngObserver
36                 lseedMainLoop False obs (constGardenSource garden) 10