~jaro/balkon

ref: 9e3b0ec7fd4a92e3d2dba81cd00dadc4dfe4006c balkon/src/Data/Text/ParagraphLayout/Internal/Line.hs -rw-r--r-- 817 bytes
9e3b0ec7Jaro Set release date for v1.3.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
module Data.Text.ParagraphLayout.Internal.Line (Line (..), shiftLine)
where

import Data.Int (Int32)

import Data.Text.ParagraphLayout.Internal.Rect

-- | Information about a line in a laid out paragraph.
data Line = Line
    { lineNumber :: Int
    -- ^ Logical number of the line box, starting at 1 for a given paragraph.
    , lineRect :: Rect Int32
    -- ^ Dimensions of the line box (CSS), containing all fragments on a given
    -- line, and matching the width of the whole paragraph.
    }
    deriving (Eq, Read, Show)

-- | Add @dx@ and @dy@ to the line's `x_origin` and `y_origin`,
-- respectively.
shiftLine :: Int32 -> Int32 -> Line -> Line
shiftLine dx dy l = l'
    where
        l' = l { lineRect = r' }
        r' = r { x_origin = x_origin r + dx, y_origin = y_origin r + dy }
        r = lineRect l