def filter.blend.clip

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

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

4586def filter.blend.clip(+c: Img.Color) -> Img.Color:
4587  Img.Color{r, g, b, a} = c
4588  +l = filter.blend.lum(c)
4589  +lo = U.min(r, U.min(g, b))
4590  +hi = U.max(r, U.max(g, b))
4591  +scaleLow = U.choose(F32, F32.is_lt(lo, 0.0), (l / U.max(0.0000001, (l - lo : F32)) : F32), 1.0)
4592  +scaleHigh = U.choose(F32, F32.is_gt(hi, 1.0), ((1.0 - l) / U.max(0.0000001, (hi - l : F32)) : F32), 1.0)
4593  filter.blend.clip.scale(c, l, (scaleLow * scaleHigh : F32))

Uses (12)

Used by (1)