autom 0.1.0.2 → 0.1.0.3
raw patch · 2 files changed
+32/−2 lines, 2 files
Files
- Graphics/Autom/Rule.hs +30/−0
- autom.cabal +2/−2
+ Graphics/Autom/Rule.hs view
@@ -0,0 +1,30 @@+{-|+Module : Graphics.Autom.Rule+Description : Helper functions for working with rules+Copyright : (c) Christopher Howard, 2016+License : GPL-3+Maintainer : ch.howard@zoho.com++These helper functions can be useful when choosing rule values.+-}+module Graphics.Autom.Rule where++import Prelude (($), flip, fromIntegral)+import Data.Word (Word8, Word32)+import Data.Bits ((.&.), shift, (.|.))++-- |Concatenates four 8-bit values.+fromQuad :: Word8 -> Word8 -> Word8 -> Word8 -> Word32+fromQuad n3 n2 n1 n0 = n3' .|. n2' .|. n1' .|. n0'+ where n3' = shift (fromIntegral n3 :: Word32) 24+ n2' = shift (fromIntegral n2 :: Word32) 16+ n1' = shift (fromIntegral n1 :: Word32) 8+ n0' = fromIntegral n0 :: Word32++-- |Splits a 32-bit value into four 8-bit values.+toQuad :: Word32 -> (Word8, (Word8, (Word8, Word8)))+toQuad x = (y3, (y2, (y1, y0)))+ where y3 = fromIntegral $ flip shift (-24) (x .&. 0xFF000000)+ y2 = fromIntegral $ flip shift (-16) (x .&. 0xFF0000)+ y1 = fromIntegral $ flip shift (-8) (x .&. 0xFF00)+ y0 = fromIntegral $ x .&. 0xFF
autom.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.0.2+version: 0.1.0.3 -- A short (one-line) description of the package. synopsis: Generates and displays patterns from next nearest neighbors cellular automata@@ -59,7 +59,7 @@ library -- Modules exported by the library.- exposed-modules: Graphics.Autom, Graphics.Autom.NextNearest, Graphics.Autom.Paint, Graphics.Autom.Display2D, Graphics.Autom.Example+ exposed-modules: Graphics.Autom, Graphics.Autom.NextNearest, Graphics.Autom.Paint, Graphics.Autom.Display2D, Graphics.Autom.Example, Graphics.Autom.Rule -- Modules included in this library but not exported. -- other-modules: