getPixelSafe method

Pixel getPixelSafe(
  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 bounds, PixelUndefined is returned.

Implementation

Pixel getPixelSafe(int x, int y, [Pixel? pixel]) {
  if (x < 0 || x >= width || y < 0 || y >= height) {
    return Pixel.undefined;
  }
  return getPixel(x, y, pixel);
}