var isInteractive = false;
img = loadImage("Carmen Sandiego.png");
brush = loadImage("brush.png");
createCanvas(img.width, img.height);
interactiveBtn = createButton('Make Interactive');
interactiveBtn.position(10, 10);
interactiveBtn.mousePressed(setInteractiveMode);
autonomousBtn = createButton('Make Autonomous');
autonomousBtn.position(10, 40);
autonomousBtn.mousePressed(setAutonomousMode);
pixelatedBtn = createButton('Make Pixelated');
pixelatedBtn.position(10, 70);
pixelatedBtn.mousePressed(setPixelatedMode);
saveBtn = createButton('Save Image');
saveBtn.position(10, 100);
saveBtn.mousePressed(saveImage);
function initializeGrid() {
for (var y = 0; y < img.height / 20; y++) {
for (var x = 0; x < img.width / 20; x++) {
function setInteractiveMode() {
function setAutonomousMode() {
function setPixelatedMode() {
saveCanvas('CarmenSandiego_' + Date.now(), 'jpg');
var gridSize = isPixelated ? 40 : 20;
for (var y = 0; y < img.height; y += gridSize) {
for (var x = 0; x < img.width; x += gridSize) {
if (revealGrid[y / gridSize][x / gridSize]) {
rect(x, y, gridSize, gridSize);
var xIndex = floor(mouseX / gridSize);
var yIndex = floor(mouseY / gridSize);
if (xIndex >= 0 && yIndex >= 0 && xIndex < img.width / gridSize && yIndex < img.height / gridSize) {
revealGrid[yIndex][xIndex] = true;
image(brush, mouseX - brushSize / 2, mouseY - brushSize / 2, brushSize, brushSize);
if (!isInteractive && !isPixelated) {
for (var i = 0; i < 10; i++) {
var xIndex = floor(random(0, img.width / gridSize));
var yIndex = floor(random(0, img.height / gridSize));
revealGrid[yIndex][xIndex] = true;
if (keyCode === UP_ARROW) {
} else if (keyCode === DOWN_ARROW) {
brushSize = max(5, brushSize - 5);