clamp paint opacity

This commit is contained in:
Ryan Oldenburg 2022-04-24 23:37:17 -05:00
parent 5b6a50d0a2
commit 328116893a
2 changed files with 7 additions and 0 deletions

View file

@ -104,6 +104,7 @@ proc fillGradientLinear(image: Image, paint: Paint) =
if paint.gradientStops.len == 0:
raise newException(PixieError, "Gradient must have at least 1 color stop")
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return
@ -177,6 +178,7 @@ proc fillGradientRadial(image: Image, paint: Paint) =
if paint.gradientStops.len == 0:
raise newException(PixieError, "Gradient must have at least 1 color stop")
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return
@ -208,6 +210,7 @@ proc fillGradientAngular(image: Image, paint: Paint) =
if paint.gradientStops.len == 0:
raise newException(PixieError, "Gradient must have at least 1 color stop")
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return

View file

@ -1922,6 +1922,8 @@ proc fillPath*(
windingRule = NonZero
) {.raises: [PixieError].} =
## Fills a path.
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return
@ -2000,6 +2002,8 @@ proc strokePath*(
dashes: seq[float32] = @[]
) {.raises: [PixieError].} =
## Strokes a path.
paint.opacity = clamp(paint.opacity, 0, 1)
if paint.opacity == 0:
return