packages feed

hgl-example-0.0.1: src/Main.hs

module Main where

import GraphicDemo as G

import System.Environment (getArgs, )
import System.Exit (exitWith, ExitCode(..), )
import Control.Monad (when, )


demos :: [(String, IO ())]
demos =
   ("text", textAnim) :
   ("triangle", dreieck) :
   ("17angle", siebzehneck) :
   ("spiral", spirale) :
   ("double-spiral", doppelSpirale) :
   ("rotating-spiral", spiraleAnim) :
   ("lissajous", lissajous) :
   ("rotating-lissajous", lissajousAnim) :
   ("rotating-star", sternAnim) :
   ("star-circle", sternenkreisAnim) :
   ("locomotive-0", wagenAnim) :
   ("locomotive-1", holperAnim0) :
   ("locomotive-2", holperAnim1) :
   ("locomotive-3", holperAnim) :
   ("sierpinski", sierpinski) :
   []


main :: IO ()
main =
   do args <- getArgs
      when (null args)
         (putStrLn "no demo name given" >>
          exitWith ExitSuccess)
      when (args == ["--list"])
         (mapM_ (putStrLn . fst) demos >>
          exitWith ExitSuccess)
      mapM_
         (\demo ->
            maybe (putStrLn $ "unkown demo: " ++ demo) id $
            lookup demo demos)
         args