Class ColorMatrixBlend
Reference implementation of Graphics.colorMatrixRegion over an ARGB buffer.
Every pixel p (channels in 0..1) becomes p + (clamp(M * p + offset) - p) * k,
where k = amount * shape * mask:
shapeis the anti-aliased coverage of a rounded rectangle filling the region,clamp(0.5 - sdf, 0, 1)at the pixel centre, with corner radiuscornerRadius(a negative radius makes a capsule; zero covers the whole rectangle);maskis the alpha of the optional mask sampled at the same relative position (nearest pixel), which is how vibrant content is drawn: the mask holds the glyphs, and each glyph pixel takes its colour from the matrix applied to what lies behind it.
The destination alpha is kept. Ports without a native path (JavaSE, the JavaScript port, iOS off-screen images) call this; the Metal shader cn1_fs_colormatrix mirrors it.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidapply(int[] argb, int w, int h, float[] matrix, int[] mask, int maskW, int maskH, float cornerRadius, float amount) Applies the blend in place.
-
Method Details
-
apply
public static void apply(int[] argb, int w, int h, float[] matrix, int[] mask, int maskW, int maskH, float cornerRadius, float amount) Applies the blend in place.
Parameters
-
argb: the destination region,w * hpixels, row major -
w: region width in pixels -
h: region height in pixels -
matrix: 12 floats, rows r, g, b of[r, g, b, offset]in 0..1 units -
mask: the mask pixels (ARGB, alpha used), or null for no mask -
maskW: mask width in pixels -
maskH: mask height in pixels -
cornerRadius: corner radius in region pixels, negative for a capsule -
amount: overall strength 0..1
-
-