hueRotationMatrix function
Calculates the hue rotation matrix for a given angle in radians.
Uses the standard NTSC luminance weights (R: 0.213, G: 0.715, B: 0.072) to produce a 4x5 color matrix suitable for ColorFilter.matrix.
Implementation
List<double> hueRotationMatrix(double angle) {
final cosT = math.cos(angle);
final sinT = math.sin(angle);
return <double>[
0.213 + 0.787 * cosT - 0.213 * sinT,
0.715 - 0.715 * cosT - 0.715 * sinT,
0.072 - 0.072 * cosT + 0.928 * sinT,
0,
0,
0.213 - 0.213 * cosT + 0.143 * sinT,
0.715 + 0.285 * cosT + 0.140 * sinT,
0.072 - 0.072 * cosT - 0.283 * sinT,
0,
0,
0.213 - 0.213 * cosT - 0.787 * sinT,
0.715 - 0.715 * cosT + 0.715 * sinT,
0.072 + 0.928 * cosT + 0.072 * sinT,
0,
0,
0,
0,
0,
1,
0,
];
}