mapScaled method

Buffer<T> mapScaled(
  1. int scale
)

Returns a lazy buffer that scales the buffer by the given factor.

The returned buffer will have the same dimensions as the original buffer multiplied by the scale factor. The scale factor must be greater than 0.

Example

final buffer = IntPixels(2, 2, data: Uint32List.fromList([
  abgr8888.red, abgr8888.green,
  abgr8888.blue, abgr8888.magenta,
]));

final scaled = buffer.mapScaled(2);
print(scaled.data); // [0xFFFF0000, 0xFFFF0000, 0xFF00FF00, 0xFF00FF00, 0xFF0000FF, 0xFF0000FF, 0xFFFF00FF, 0xFFFF00FF]

Implementation

Buffer<T> mapScaled(int scale) {
  RangeError.checkNotNegative(scale, 'scale');
  if (scale == 1) {
    return this;
  }
  return _ScaledBuffer(this, scale);
}