Float32x4Pixels constructor

Float32x4Pixels(
  1. int width,
  2. int height, {
  3. PixelFormat<Float32x4, void> format = floatRgba,
  4. Float32x4List? data,
})

Creates a new buffer of multi-channel floating point pixel data.

Both width and height must be greater than zero.

The format defaults to floatRgba, and if data is provided it's contents must are assumed to be in the same format, and data.length must be equal to width * height.

Implementation

factory Float32x4Pixels(
  int width,
  int height, {
  PixelFormat<Float32x4, void> format = floatRgba,
  Float32x4List? data,
}) {
  if (width < 1) {
    throw ArgumentError.value(width, 'width', 'Must be greater than zero.');
  }
  if (height < 1) {
    throw ArgumentError.value(height, 'height', 'Must be greater than zero.');
  }
  if (data == null) {
    data = Float32x4List(width * height);
    if (format.zero.equal(Float32x4.zero()).signMask == 0) {
      data.fillRange(0, data.length, format.zero);
    }
  } else if (data.length != width * height) {
    throw RangeError.value(
      data.length,
      'data.length',
      'Must be equal to width * height.',
    );
  }
  return Float32x4Pixels._(
    data,
    width: width,
    height: height,
    format: format,
  );
}