mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-02 11:05:10 +03:00
Bugfix: fix negative cropping in hCenter, vCenter, and cropResultToContext
This commit is contained in:
parent
77aae73810
commit
5ed4955179
@ -37,9 +37,9 @@ hCenterWith mChar p =
|
||||
c <- getContext
|
||||
let rWidth = result^.imageL.to imageWidth
|
||||
rHeight = result^.imageL.to imageHeight
|
||||
remainder = c^.availWidthL - (leftPaddingAmount * 2)
|
||||
leftPaddingAmount = (c^.availWidthL - rWidth) `div` 2
|
||||
rightPaddingAmount = leftPaddingAmount + remainder
|
||||
remainder = max 0 $ c^.availWidthL - (leftPaddingAmount * 2)
|
||||
leftPaddingAmount = max 0 $ (c^.availWidthL - rWidth) `div` 2
|
||||
rightPaddingAmount = max 0 $ leftPaddingAmount + remainder
|
||||
leftPadding = charFill (c^.attrL) ch leftPaddingAmount rHeight
|
||||
rightPadding = charFill (c^.attrL) ch rightPaddingAmount rHeight
|
||||
paddedImage = horizCat [ leftPadding
|
||||
@ -67,9 +67,9 @@ vCenterWith mChar p =
|
||||
c <- getContext
|
||||
let rWidth = result^.imageL.to imageWidth
|
||||
rHeight = result^.imageL.to imageHeight
|
||||
remainder = c^.availHeightL - (topPaddingAmount * 2)
|
||||
topPaddingAmount = (c^.availHeightL - rHeight) `div` 2
|
||||
bottomPaddingAmount = topPaddingAmount + remainder
|
||||
remainder = max 0 $ c^.availHeightL - (topPaddingAmount * 2)
|
||||
topPaddingAmount = max 0 $ (c^.availHeightL - rHeight) `div` 2
|
||||
bottomPaddingAmount = max 0 $ topPaddingAmount + remainder
|
||||
topPadding = charFill (c^.attrL) ch rWidth topPaddingAmount
|
||||
bottomPadding = charFill (c^.attrL) ch rWidth bottomPaddingAmount
|
||||
paddedImage = vertCat [ topPadding
|
||||
|
@ -42,4 +42,4 @@ cropToContext p =
|
||||
cropResultToContext :: Result -> RenderM Result
|
||||
cropResultToContext result = do
|
||||
c <- getContext
|
||||
return $ result & imageL %~ (V.crop (c^.availWidthL) (c^.availHeightL))
|
||||
return $ result & imageL %~ (V.crop (max 0 $ c^.availWidthL) (max 0 $ c^.availHeightL))
|
||||
|
Loading…
Reference in New Issue
Block a user