def sample
gralha-svg-render@0.1.0.1 · svg.bend:2923
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
2923def sample(+scenes: List<&2, Scene<Brush>>, +p: Point, +paintPoint: Point, +back: Img.Color, +linear: Bool, +limit: F32) -> Img.Color:
2924 match scenes:
2925 case Nil{}: back
2926 case Con{Scene{es, box, inv, style, opacity, kids, id, ink, mask, outline, fillTree, maskNodes, maskMode, markerNodes, coverage, effect}, rest}:
2927 +cc = clip.cover(mask, p)
2928 +inner = U.min(limit, cc)
2929 +gate = U.choose(F32, filter.rendered(effect), cc, U.choose(F32, F32.is_gt(inner, 0.0), 1.0, 0.0))
2930 sample(rest, p, paintPoint, U.branch(Img.Color, bounds.inside(coverage, p, 0.01), _ => color.over(mask.apply(clip.fade(gate, _ => filter.sample(effect, paintPoint, linear, _ => sample(kids, p, paintPoint,
2931 scene.local(Scene{es, box, inv, style, opacity, kids, id, ink, mask, outline, fillTree, maskNodes, maskMode, markerNodes, coverage, effect}, p, paintPoint, linear, sample(markerNodes, p, paintPoint, Img.clear(), linear, inner),
2932 nodes => q => center => sample(nodes, q, center, Img.clear(), False{}, 1.0),
2933 nodes => q => center => sample(nodes, q, center, Img.clear(), False{}, 1.0), inner), linear, inner))),
2934 opacity, maskMode, _ => sample(maskNodes, p, paintPoint, Img.clear(), U32.is_eq(maskMode, 3), 1.0)), back), _ => back), linear, limit)