copyWith method

  1. @override
int copyWith(
  1. int pixel, {
  2. int? gray,
})
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
int copyWith(int pixel, {int? gray}) {
  var output = pixel;
  if (gray != null) {
    output = gray & 0xFF;
  }
  return output;
}