mask resize

This commit is contained in:
Ryan Oldenburg 2022-06-07 23:50:04 -05:00
parent b3999b0598
commit 6b843f9404
2 changed files with 16 additions and 0 deletions

View file

@ -156,6 +156,7 @@ exportRefObject Mask:
applyOpacity(Mask, float32)
invert(Mask)
blur(Mask, float32, uint8)
resize(Mask, int, int)
draw(Mask, Mask, Mat3, BlendMode)
draw(Mask, Image, Mat3, BlendMode)
fillText(Mask, Font, string, Mat3, Vec2, HorizontalAlignment, VerticalAlignment)

View file

@ -1155,6 +1155,21 @@ proc resize*(srcImage: Image, width, height: int): Image {.raises: [PixieError].
OverwriteBlend
)
proc resize*(srcMask: Mask, width, height: int): Mask {.raises: [PixieError].} =
## Resize a mask to a given height and width.
if width == srcMask.width and height == srcMask.height:
result = srcMask.copy()
else:
result = newMask(width, height)
result.draw(
srcMask,
scale(vec2(
width.float32 / srcMask.width.float32,
height.float32 / srcMask.height.float32
)),
OverwriteBlend
)
proc shadow*(
image: Image, offset: Vec2, spread, blur: float32, color: SomeColor
): Image {.raises: [PixieError].} =