setPixelSafe method

void setPixelSafe(
  1. int x,
  2. int y,
  3. int color
)

Set the pixel at the given x, y coordinate to the color. If the pixel coordinates are out of bounds, nothing is done.

Implementation

void setPixelSafe(int x, int y, int color) {
  if (boundsSafe(x, y)) {
    data[y * width + x] = color;
  }
}