copyWithNormalized method

  1. @override
int copyWithNormalized(
  1. int pixel, {
  2. double? gray,
})
override

Returns a copy of the pixel with normalized values.

Subclasses override this method to provide named parameters for channels.

Example

print(abgr8888.copyWithNormalized(0x12345678, red: 1.0)); // 0xFF345678
print(floatRgba.copyWithNormalized(Float32x4(0.1, 0.2, 0.3, 0.4), red: 0.5)); // [0.5, 0.2, 0.3, 0.4]

Implementation

@override
int copyWithNormalized(int pixel, {double? gray}) {
  return copyWith(
    pixel,
    gray: gray != null ? (gray.clamp(0.0, 1.0) * 0xFF).floor() : null,
  );
}