ColorOption.rotate constructor
Copy from android sdk. See Android SDK color matrix .
Implementation
factory ColorOption.rotate(int axis, double degrees) {
final mArray = List<double>.from(defaultColorMatrix);
double radians = degrees * math.pi / 180;
final cosine = math.cos(radians);
final sine = math.sin(radians);
switch (axis) {
// Rotation around the red color
case 0:
mArray[6] = mArray[12] = cosine;
mArray[7] = sine;
mArray[11] = -sine;
break;
// Rotation around the green color
case 1:
mArray[0] = mArray[12] = cosine;
mArray[2] = -sine;
mArray[10] = sine;
break;
// Rotation around the blue color
case 2:
mArray[0] = mArray[6] = cosine;
mArray[1] = sine;
mArray[5] = -sine;
break;
default:
throw ArgumentError('Failed to create');
}
return ColorOption(matrix: mArray);
}