never executed always true always false
1 module HelVM.HelMA.Automata.Piet.Image where
2
3 import Data.Array.IArray
4 import HelVM.HelMA.Automata.Piet.Coordinates
5
6 -- | Constructors
7
8 newEmptyImage :: Coordinates -> Image a
9 newEmptyImage = newImage []
10
11 newImage :: [(Coordinates, a)] -> Coordinates -> Image a
12 newImage entries c = array ((0 , 0) , c) entries
13
14 imgSetPixel :: Coordinates -> a -> Image a -> Image a
15 imgSetPixel c pixel img = img // [(c, pixel)]
16
17 -- | Getters
18 unsafeLoopUp :: Coordinates -> Image a -> a
19 unsafeLoopUp = flip (!)
20
21 border :: Image a -> Coordinates
22 border = snd . bounds
23
24 -- | Type
25 type Image a = Array Coordinates a