getPixelClamped method

Pixel getPixelClamped(
  1. int x,
  2. int y, [
  3. Pixel? pixel
])

Get the pixel from the given x, y coordinate. If the pixel coordinates are out of range of the image, they will be clamped to the resolution.

Implementation

Pixel getPixelClamped(int x, int y, [Pixel? pixel]) {
  x = x.clamp(0, width - 1);
  y = y.clamp(0, height - 1);
  return getPixel(x, y, pixel);
}