setPixelRgbSafe method

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

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

Implementation

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