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
- arrayBox :: IArray a e => a YX e -> Maybe Box
- boundingBox :: Foldable f => f YX -> Maybe Box
- boxBounds :: Box -> (YX, YX)
- topLeft :: Box -> YX
- bottomRight :: Box -> YX
- boxHeight :: Box -> Int
- boxWidth :: Box -> Int
- inBox :: YX -> Box -> Bool
- boxDepth :: Box -> YX -> Maybe Int
- boxRange :: Box -> [YX]
- boxRows :: Box -> [[YX]]
- boxIntersection :: Box -> Box -> Maybe Box
- boxNeighbors4 :: Box -> YX -> [YX]
- boxNeighbors8 :: Box -> YX -> [YX]
- 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)
- byteStringToArrayM :: (IArray a e, MonadError String m) => (YX -> Char -> m e) -> ByteString -> m (a YX e)
- arrayToByteString :: IArray a e => (e -> Char) -> a YX e -> ByteString
Coordinate type
A 2D coordinate.
Basic steps
Box
A non-empty 2D box.
A box might have zero width or height but will always contain at least one point.
Constructs a box from its extremities, returning Nothing
if the points are not ordered
appropriately.
arrayBox :: IArray a e => a YX e -> Maybe Box Source #
Returns the box corresponding to an array, or Nothing
if the array is empty.
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).
boxDepth :: Box -> YX -> Maybe Int Source #
Returns the shortest distance of the point to the box' edge, or Nothing
if the point is not
within the box.
Since: 0.0.4.2
boxNeighbors4 :: Box -> YX -> [YX] Source #
Returns 4 neighbors of YX filtered to members of the box.
Since: 0.0.4.0
boxNeighbors8 :: Box -> YX -> [YX] Source #
Returns 8 neighbors of YX filtered to members of the box.
Since: 0.0.4.0
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.
byteStringToArrayM :: (IArray a e, MonadError String m) => (YX -> Char -> m e) -> ByteString -> m (a YX e) Source #
Parses a newline delimited bytestring into an array in an effectful way.
Since: 0.0.4.0
arrayToByteString :: IArray a e => (e -> Char) -> a YX e -> ByteString Source #
Serializes an array into a bytestring. This function is the reverse of byteStringToArray
.