A module providing a couple of Piet-specific types and simple associated functions needed throughout the library.
- data DirectionPointer
- addCoordinates :: DirectionPointer -> Int -> Int -> (Int, Int)
- rotate :: Int -> DirectionPointer -> DirectionPointer
- data CodelChooser
- toggle :: Int -> CodelChooser -> CodelChooser
- data PietType
- = PietNumber
- | PietChar
- data Program = Program {}
- isBlocked :: Int -> Int -> Program -> Bool
- data Colour
- rgba2Colour :: Num w => w -> w -> w -> w -> Colour
- rgb2Colour :: Num w => w -> w -> w -> Colour
- data HueColour
- hueChange :: HueColour -> HueColour -> HueColour
- data Lightness
- lightnessChange :: Lightness -> Lightness -> Lightness
- data Image a
- imgWidth :: Image a -> Int
- imgHeight :: Image a -> Int
- imgInRange :: Int -> Int -> Image a -> Bool
- imgNew :: Int -> Int -> [((Int, Int), a)] -> Image a
- imgPixel :: Int -> Int -> Image a -> a
- imgSetPixel :: Int -> Int -> a -> Image a -> Image a
- type LabelKey = Int
- data LabelInfo
- = EmptyInfo
- | LabelInfo {
- _labelSize :: !Int
- labelTop :: !LabelBorder
- labelLeft :: !LabelBorder
- labelBottom :: !LabelBorder
- labelRight :: !LabelBorder
- labelSize :: LabelInfo -> Int
- addPixel :: Int -> Int -> LabelInfo -> LabelInfo
- data LabelBorder = LabelBorder {}
Piet Interpreter
Direction Pointer and Codel Chooser
data DirectionPointer Source
The Direction Pointer (DP).
:: DirectionPointer | Direction to move to |
-> Int | x-coordinate |
-> Int | y-coordinate |
-> (Int, Int) | New x-/y-coordinates |
Move coordinates by one in the direction of the DirectionPointer
.
rotate :: Int -> DirectionPointer -> DirectionPointerSource
Rotate a DirectionPointer
clockwise (counter clockwise if the Int
is
negative) a given number of times.
data CodelChooser Source
The Codel Chooser (CC).
toggle :: Int -> CodelChooser -> CodelChooserSource
Toggle a CodelChooser
a given number of times.
Piet's type system
Piet types. Relevant to distinguish in-/output strategies.
Runtime program representation
Runtime program representation.
isBlocked :: Int -> Int -> Program -> BoolSource
Returns if a given codel in a program is blocked in the Piet
sense (which is the case when it is out of the image's range or
Black
).
Colour system
The colours that make up a Piet program text.
Converts red/green/blue/alpha values to a Colour
. The alpha channel
is ignored for now, but may be used in future implementations or
dialects, so please use this function instead of rgb2Colour
whenever
an alpha channel is available.
Piet colours in the hue cycle.
Hue lightness values supported by Piet.
lightnessChange :: Lightness -> Lightness -> LightnessSource
Images
An image. Its coordinates will be (0, 0) .. (width-1, height-1)
Find out, if the given coordinates are within the Image
borders (which are (0, 0) .. (width-1, height-1)
).
Build a new image.
Access a pixel at given x/y-coordinates.
Stores compiler-relevant information about a label. This type
implements an instance of Monoid
to merge labels.
EmptyInfo | The empty label |
LabelInfo | Label with a size and four borders |
|
labelSize :: LabelInfo -> IntSource
Number of pixels in a label. This function is defined for all
constructors of LabelInfo
so, in contrast to _labelSize
, it
won't fail on EmptyInfo
.
data LabelBorder Source
Holds information of a label (coloured area) relevant for the Piet language, i. e. information about where the program flow will be directed regarding a Direction Pointer.
Holds a border position (e. g. an x-coordinate) and the minimum or maximum associated "other" coordinates (e. g. y-coordinates).