| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Data.Text.ParagraphLayout.Rect
Description
Representation of an axis-aligned rectangle on a 2D plane, with one of its corners being a designated origin point.
Synopsis
- data Rect a = Rect {}
- height :: Num a => Rect a -> a
- width :: Num a => Rect a -> a
- x_max :: (Num a, Ord a) => Rect a -> a
- x_min :: (Num a, Ord a) => Rect a -> a
- x_terminus :: Num a => Rect a -> a
- y_max :: (Num a, Ord a) => Rect a -> a
- y_min :: (Num a, Ord a) => Rect a -> a
- y_terminus :: Num a => Rect a -> a
- union :: (Num a, Ord a) => Bias -> Rect a -> Rect a -> Rect a
- unionMany :: (Num a, Ord a) => Bias -> [Rect a] -> Maybe (Rect a)
- unionMany1 :: (Num a, Ord a) => Bias -> NonEmpty (Rect a) -> Rect a
- data Bias
Documentation
An axis-aligned rectangle on a 2D plane.
Constructors
| Rect | |
Fields
| |
Instances
| Eq a => Eq (Rect a) | |
| Read a => Read (Rect a) | |
Defined in Data.Text.ParagraphLayout.Internal.Rect | |
| Show a => Show (Rect a) | |
height :: Num a => Rect a -> a #
Absolute difference between the Y coordinates of the rectangle's sides.
width :: Num a => Rect a -> a #
Absolute difference between the X coordinates of the rectangle's sides.
x_max :: (Num a, Ord a) => Rect a -> a #
The larger of the two X coordinates of the rectangle's edges.
x_min :: (Num a, Ord a) => Rect a -> a #
The smaller of the two X coordinates of the rectangle's edges.
x_terminus :: Num a => Rect a -> a #
X coordinate of the corner opposite of the origin.
y_max :: (Num a, Ord a) => Rect a -> a #
The larger of the two Y coordinates of the rectangle's edges.
y_min :: (Num a, Ord a) => Rect a -> a #
The smaller of the two Y coordinates of the rectangle's edges.
y_terminus :: Num a => Rect a -> a #
Y coordinate of the corner opposite of the origin.
union :: (Num a, Ord a) => Bias -> Rect a -> Rect a -> Rect a #
The smallest rectangle completely containing the given two rectangles.
The origin of the output rectangle will be set according to Bias,
regardless of which corners of the input rectangles are designated
as their origins.
Note that this operation has no identity element. A rectangle whose
x_size and/or y_size are zero is not considered null or neutral,
but effectively acts as a point, which will be contained in the union.
You can use Nothing as an identity element if you lift this operation
over the Maybe applicative functor:
liftA2(unionbias)
unionMany :: (Num a, Ord a) => Bias -> [Rect a] -> Maybe (Rect a) #
Just the union of all given rectangles, or Nothing if none are given.
unionMany1 :: (Num a, Ord a) => Bias -> NonEmpty (Rect a) -> Rect a #
The union of all given rectangles, where at least one must be given.
Note that adding a default value to the input list to make it non-empty
will probably not do what you want, since the union operation has no
identity element.
If you need a default output value for empty inputs, consider using:
fromMaybeyourDefaultValue $unionManybias rects
Determines which corner of a calculated rectangle should be its origin.