balkon-1.3.0.0: Text layout engine built on top of HarfBuzz.
Safe HaskellSafe
LanguageHaskell2010

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

Documentation

data Rect a #

An axis-aligned rectangle on a 2D plane.

Constructors

Rect 

Fields

  • x_origin :: a

    X coordinate of the corner designated as the rectangle's origin.

  • y_origin :: a

    Y coordinate of the corner designated as the rectangle's origin.

  • x_size :: a

    Signed difference between the X coordinates of the rectangle's sides.

  • y_size :: a

    Signed difference between the Y coordinates of the rectangle's sides.

Instances

Instances details
Eq a => Eq (Rect a) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Rect

Methods

(==) :: Rect a -> Rect a -> Bool

(/=) :: Rect a -> Rect a -> Bool

Read a => Read (Rect a) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Rect

Methods

readsPrec :: Int -> ReadS (Rect a)

readList :: ReadS [Rect a]

readPrec :: ReadPrec (Rect a)

readListPrec :: ReadPrec [Rect a]

Show a => Show (Rect a) 
Instance details

Defined in Data.Text.ParagraphLayout.Internal.Rect

Methods

showsPrec :: Int -> Rect a -> ShowS

show :: Rect a -> String

showList :: [Rect a] -> ShowS

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 (union bias)

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:

fromMaybe yourDefaultValue $ unionMany bias rects

data Bias #

Determines which corner of a calculated rectangle should be its origin.

Constructors

LL

Set the origin as the corner with low X and low Y coordinates.

LH

Set the origin as the corner with low X and high Y coordinates.

HL

Set the origin as the corner with high X and low Y coordinates.

HH

Set the origin as the corner with high X and high Y coordinates.