def pixel.mask

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

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

5184# The mask factor a packed pixel gives: its alpha, or the luminance of its premultiplied color.
5185def pixel.mask(+px: U32, +mode: U32) -> F32:
5186  U.choose(F32, U32.is_eq(mode, 1), (U32.to_f32(pixel.lane(px, 16777216)) / 255.0 : F32),
5187    ((U32.to_f32(pixel.lane(px, 1)) * 0.2126 + U32.to_f32(pixel.lane(px, 256)) * 0.7152 + U32.to_f32(pixel.lane(px, 65536)) * 0.0722) / 255.0 : F32))

Uses (9)

Used by (1)