public float getPixelSafe(int x, int y) { if (x < 0 || x >= width || y < 0 || y >= height) { return 0f; } else { return pixels[y,x]; } }