def filter.convolution.finish

gralha-svg-render@0.1.0.1 · svg.bend:4701

import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-image@0.1.0.1/image.bend as Img

4701def filter.convolution.finish(+c: Img.Color, +divisor: F32, +bias: F32, +preserve: Bool, original: Img.Color) -> Img.Color:
4702  Img.Color{r, g, b, a} = c
4703  Img.Color{rr, gg, bb, aa} = original
4704  +alpha = U.choose(F32, preserve, aa, (a / divisor + bias : F32))
4705  U.branch(Img.Color, preserve,
4706    _ => color.premultiply(Img.Color{(r / divisor + bias : F32), (g / divisor + bias : F32), (b / divisor + bias : F32), alpha}),
4707    _ => color.premul.clamp(Img.Color{(r / divisor + bias * alpha : F32), (g / divisor + bias * alpha : F32), (b / divisor + bias * alpha : F32), alpha}))

Uses (10)

Used by (1)