From 191b89b50cfc44754eca3246b8e694e413ab094e Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Mon, 8 Feb 2021 16:39:24 -0600 Subject: [PATCH] mask applyOpacity --- src/pixie/masks.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pixie/masks.nim b/src/pixie/masks.nim index 101336d..c600409 100644 --- a/src/pixie/masks.nim +++ b/src/pixie/masks.nim @@ -109,5 +109,11 @@ proc getValueSmooth*(mask: Mask, x, y: float32): uint8 = lerp(bottomMix, topMix, diffY) +proc applyOpacity*(mask: Mask, opacity: float32) = + ## Multiplies the values of the mask by opacity. + let opacity = round(255 * opacity).uint32 + for value in mask.data.mitems: + value = ((value * opacity) div 255).uint8 + when defined(release): {.pop.}