~jaro/balkon

ref: 0e108aa71ac0cce0b8d819a0528dba4be37c9bf6 balkon/src/Data/Text/ParagraphLayout/Internal/ParagraphExtents.hs -rw-r--r-- 925 bytes
0e108aa7Jaro Set release date for v1.2.0.0 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module Data.Text.ParagraphLayout.Internal.ParagraphExtents
    ( paragraphOriginX
    , paragraphOriginY
    , containRects
    , emptyRect
    )
where

import Data.Maybe (fromMaybe)

import Data.Text.ParagraphLayout.Internal.Rect

-- | X coordinate used as the left edge of every paragraph.
paragraphOriginX :: (Num a) => a
paragraphOriginX = 0

-- | Y coordinate used as the top edge of every paragraph.
paragraphOriginY :: (Num a) => a
paragraphOriginY = 0

-- | A `Rect` located at the top left corner of a paragraph,
-- with zero size in each dimension.
emptyRect :: (Num a) => Rect a
emptyRect = Rect
    { x_origin = paragraphOriginX
    , y_origin = paragraphOriginY
    , x_size = 0
    , y_size = 0
    }

-- | Smallest rectangle containing the given rectangles,
-- or `emptyRect` if none are given.
containRects :: (Num a, Ord a) => [Rect a] -> Rect a
containRects rects = fromMaybe emptyRect $ unionMany LH rects