xxxxxxxxxx
71
let selectionIndex = 0;
let textColor;
let selectedColor;
let nonSelectedColor;
function setup()
{
createCanvas(windowWidth, windowHeight);
textColor = color(255, 210);
selectedColor = color(80, 220, 140);
nonSelectedColor = color(20, 180, 250);
rectMode(CENTER);
textAlign(CENTER, CENTER);
}
function draw()
{
background(40);
DrawWindow();
}
function DrawWindow()
{
strokeWeight(8);
stroke(255, 120);
fill(255, 80);
let windowX = windowWidth / 2;
let windowY = windowHeight / 2;
let w = 420;
let h = 200;
rect(windowX, windowY, w, h, 30);
textSize(60);
textStyle(ITALIC);
noStroke();
fill(textColor);
let topTextX = windowX;
let topTextY = windowY - 40;
text("Are you sure?", topTextX, topTextY);
textStyle(BOLD);
fill(selectionIndex === 0 ? selectedColor : nonSelectedColor);
let yesX = windowX - 80;
let yesY = windowY + 48;
text("Yes", yesX, yesY);
fill(selectionIndex === 1 ? selectedColor : nonSelectedColor);
let noX = windowX + 80;
let noY = yesY;
text("No", noX, noY);
}
function keyPressed()
{
if (keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW)
selectionIndex = (selectionIndex + 1) % 2;
}