toFloatRgba method
- int pixel
inherited
Converts a pixel in this
pixel format to the floatRgba pixel format.
FLOAT_RGBA is used as the canonical floating-point pixel format, and this
method guarantees that all pixel formats can be converted to it. Loss of
precision may occur when this
pixel format has higher precision.
Example
print(floatRgba.toFloatRgba(abgr8888.red)); // [1.0, 0.0, 0.0, 1.0]
print(floatRgba.toFloatRgba(abgr8888.white)); // [1.0, 1.0, 1.0, 1.0]
Implementation
@override
@nonVirtual
Float32x4 toFloatRgba(int pixel) {
final r = getRed(pixel) / 255.0;
final g = getGreen(pixel) / 255.0;
final b = getBlue(pixel) / 255.0;
final a = getAlpha(pixel) / 255.0;
return Float32x4(r, g, b, a);
}