Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
GUI docu.
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-jana committed Oct 8, 2015
1 parent 0baf219 commit 7285ed2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions GUI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import Data.Word (Word8)

import CellularAutomata2D

-- | Colors for the different cell values.
-- | On my machine mapRGBA didn't work, so I created my own colors
-- | using bitoperations.
type Color = SDL.Pixel

getColorFromRGB255 :: Word8 -> Word8 -> Word8 -> Color
Expand All @@ -36,6 +39,13 @@ orange = getColorFromRGB255 255 165 0
targetScreenWidth :: Int
targetScreenWidth = 500

-- | Runs a GUI for a 2d cellular automata using
-- | a given starting space, a list of cell states witch can be used
-- | by the user to edit the space, a function witch takes a cell states
-- | and returns a color to draw the individual cells and a rule that is
-- | used to updated the space.
-- | The user can press space to start and stop the simulation of the automata.
-- | He can also edit the space by clicking into a cell witch goes to the next state.
runCellularAutomata2D :: (Space s, Eq a) => s a -> [a] -> (a -> Color) ->
Rule s a -> IO ()
runCellularAutomata2D space states colors updateCell = do
Expand Down

0 comments on commit 7285ed2

Please sign in to comment.