Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Bitmap-friendly XY coordinates.
We use YX
rather than XY
to allow natural row major order (first row sorts before the second,
etc.). Note that rows are assumed to go down with y
.
Synopsis
- data YX = YX {}
- up :: YX
- left :: YX
- right :: YX
- down :: YX
- steps4 :: [YX]
- steps8 :: [YX]
- data Box
- box :: YX -> YX -> Maybe Box
- boundingBox :: Foldable f => f YX -> Maybe Box
- topLeft :: Box -> YX
- bottomRight :: Box -> YX
- boxHeight :: Box -> Int
- boxWidth :: Box -> Int
- inBox :: YX -> Box -> Bool
- boxRange :: Box -> [YX]
- boxRows :: Box -> [[YX]]
- boxIntersection :: Box -> Box -> Maybe Box
- data Center
- data Direction
- rotate :: Direction -> Center -> YX -> YX
- data Axis
- mirror :: Axis -> YX -> YX
- byteStringToArray :: IArray a e => (Char -> Maybe e) -> ByteString -> Either String (a YX e)
- arrayToByteString :: IArray a e => (e -> Char) -> a YX e -> ByteString
Coordinate type
A 2D coordinate.
YX implements Num
. Integers are converted to their diagonal equivalent (for example 2
becomes
YX 2 2
).
Basic steps
Box
A 2D box.
A box might have zero width or height.
Constructs a box from its extremities, returning Nothing
if the points are not ordered
appropriately.
boundingBox :: Foldable f => f YX -> Maybe Box Source #
Returns the smallest Box
containing all input coordinates.
bottomRight :: Box -> YX Source #
Returns the bottom-right most point of the box (i.e. its lattice join).
Transformations
The center of a rotation.
Valid rotations can have either an exact coordinate as center or the top left corner of a coordinate.
A rotational direction.
Instances
Bounded Direction Source # | |
Enum Direction Source # | |
Defined in Data.Geometry.YX succ :: Direction -> Direction # pred :: Direction -> Direction # fromEnum :: Direction -> Int # enumFrom :: Direction -> [Direction] # enumFromThen :: Direction -> Direction -> [Direction] # enumFromTo :: Direction -> Direction -> [Direction] # enumFromThenTo :: Direction -> Direction -> Direction -> [Direction] # | |
Eq Direction Source # | |
Ord Direction Source # | |
Defined in Data.Geometry.YX | |
Show Direction Source # | |
Serialization
byteStringToArray :: IArray a e => (Char -> Maybe e) -> ByteString -> Either String (a YX e) Source #
Parses a newline delimited bytestring into an array.
arrayToByteString :: IArray a e => (e -> Char) -> a YX e -> ByteString Source #
Serializes an array into a bytestring. This function is the reverse of byteStringToArray
.