setPixelRgbaSafe method

void setPixelRgbaSafe(
  1. int x,
  2. int y,
  3. num r,
  4. num g,
  5. num b,
  6. num a,
)

Calls setPixelRgba, but ensures x and y are within the extents of the image, otherwise it returns without setting the pixel.

Implementation

void setPixelRgbaSafe(int x, int y, num r, num g, num b, num a) {
  if (x < 0 || x >= width || y < 0 || y >= height) {
    return;
  }
  setPixelRgba(x, y, r, g, b, a);
}