~jaro/balkon

ref: 7dc45d1deab5d7d7e967fe2056f322f0dabac0bc balkon/src/Data/Text/ParagraphLayout/Internal/ParagraphExtents.hs -rw-r--r-- 925 bytes
7dc45d1dJaro Implement vertical alignment. 1 year, 2 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