copyWith method
override
Returns a copy of the pixel
.
Subclasses override this method to provide named parameters for channels.
Example
print(abgr8888.copyWith(0x12345678, red: 0x9A)); // 0x9A345678
print(floatRgba.copyWith(Float32x4(0.1, 0.2, 0.3, 0.4), red: 0.5)); // [0.5, 0.2, 0.3, 0.4]
Implementation
@override
Float32x4 copyWith(
Float32x4 pixel, {
double? red,
double? green,
double? blue,
double? alpha,
}) {
final output = Float32x4(
red ?? getRed(pixel),
green ?? getGreen(pixel),
blue ?? getBlue(pixel),
alpha ?? getAlpha(pixel),
);
return output.clamp(zero, max);
}