def gradient.interval

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

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

2162def gradient.interval(xs: List<&2, Stop>, +previous: Stop, +t: F32) -> Img.Color:
2163  match xs:
2164    case Nil{}:
2165      Stop{o, c} = previous
2166      c
2167    case Con{Stop{o, c}, rest}:
2168      Stop{po, pc} = previous
2169      +offset = o
2170      +ink = c
2171      U.branch(Img.Color, F32.is_lt(t, offset),
2172        _ => gradient.mix(pc, ink, U.clamp(((t - po) / U.max(0.0000001, (offset - po : F32)) : F32), 0.0, 1.0)),
2173        _ => gradient.interval(rest, Stop{offset, ink}, t))

Uses (11)

Used by (1)