def stop.color

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

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

2134def stop.color(c: Img.Color, opacity: F32, +linear: Bool) -> Img.Color:
2135  Img.Color{r, g, b, a} = c
2136  +alpha = a
2137  +rr = (r / U.max(0.0000001, alpha) : F32)
2138  +gg = (g / U.max(0.0000001, alpha) : F32)
2139  +bb = (b / U.max(0.0000001, alpha) : F32)
2140  Img.Color{U.choose(F32, linear, srgb.linear(rr), rr), U.choose(F32, linear, srgb.linear(gg), gg),
2141    U.choose(F32, linear, srgb.linear(bb), bb), (alpha * opacity : F32)}

Uses (8)

Used by (1)