diff --git a/Graphics/Config.hs b/Graphics/Config.hs new file mode 100644 index 0000000..3add0d8 --- /dev/null +++ b/Graphics/Config.hs @@ -0,0 +1,12 @@ +module Graphics.Config where + +import FRP.Yampa (Time) +import GOL.Rule (Rule) +import Graphics.Gloss (Color) + +data Config = Config + { cellColor :: Color, + rule :: Rule, + tickRate :: Time, + windowSize :: (Int, Int) + } \ No newline at end of file diff --git a/Graphics/Display.hs b/Graphics/Display.hs index 32bf100..fa156f8 100644 --- a/Graphics/Display.hs +++ b/Graphics/Display.hs @@ -6,6 +6,7 @@ module Graphics.Display where import Control.Monad.Representable.Reader import Data.Maybe (mapMaybe) import GOL.Space +import Graphics.Config import Graphics.Gloss -- * Drawing the display grid @@ -27,7 +28,8 @@ drawCells xs size = let poss = (,) <$> [0 .. sizex @f -1] <*> [0 .. sizey @f -1] in mapMaybe (\pos -> drawCell xs pos size) poss -drawGrid :: forall f. DisplayableSpace f => f Bool -> (Int, Int) -> Picture -drawGrid xs (w, h) = - let size = fromIntegral $ if w > h then h `div` sizey @f else w `div` sizex @f - in color white $ pictures $ drawCells xs size \ No newline at end of file +drawGrid :: forall f. DisplayableSpace f => Config -> f Bool -> Picture +drawGrid config xs = + let (w, h) = windowSize config + size = fromIntegral $ if w > h then h `div` sizey @f else w `div` sizex @f + in color (cellColor config) $ pictures $ drawCells xs size \ No newline at end of file diff --git a/conways-game-of-life.cabal b/conways-game-of-life.cabal index 182f913..66ea785 100644 --- a/conways-game-of-life.cabal +++ b/conways-game-of-life.cabal @@ -12,6 +12,7 @@ executable main GOL.Space, GOL.Engine, Graphics.GlossUtils, + Graphics.Config, Graphics.Engine, Graphics.Display build-depends: base,