public final class ColorMatrixBlend
- Object
- 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.
Methods
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. |
Inherited methods
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
argbint[]- the destination region,
w * hpixels, row major wint- region width in pixels
hint- region height in pixels
matrixfloat[]- 12 floats, rows r, g, b of
[r, g, b, offset]in 0..1 units maskint[]- the mask pixels (ARGB, alpha used), or null for no mask
maskWint- mask width in pixels
maskHint- mask height in pixels
cornerRadiusfloat- corner radius in region pixels, negative for a capsule
amountfloat- overall strength 0..1