getBackground method
Gets the background color at (x, y). Returns 0 if coordinates are out of bounds.
Implementation
int getBackground(int x, int y) {
if (x < 0 || x >= width || y < 0 || y >= height) return 0;
return attributes[(y * width + x) * 3 + 1];
}