sourceOver function

UvColor? sourceOver(
  1. UvColor? src,
  2. UvColor? dst
)

Composites src over dst using Porter-Duff SourceOver.

When src is a translucent UvRgb, this blends it over dst using integer arithmetic and returns an opaque UvRgb. Non-RGB colors fall back to source replacement semantics.

Implementation

UvColor? sourceOver(UvColor? src, UvColor? dst) {
  if (src == null) return dst;
  return switch (src) {
    UvRgb() => _sourceOverRgb(src, dst),
    _ => src,
  };
}