xxxxxxxxxx
let a;
function setup() {
createCanvas(400, 400);
a = 100;
}
function draw() {
background(255);
// Add some text behind the shape so that we can
// more easily visualize the transparency
stroke(0);
textSize(32);
text("hi", width/2 - 12, height/2 + 12);
// Draw that shape!
noStroke();
fill(169, 255, 231, a);
ellipse(width/2, height/2, 200);
// Update the alpha based on the key I'm pressing
if (keyIsPressed) {
if (keyCode == LEFT_ARROW) {
// Lower the alpha if it can be lowered
if (a > 0) {
a -= 1;
}
} else if (keyCode == RIGHT_ARROW) {
// Raise the alpha if it can be raised
if (a < 255) {
a += 1;
}
}
}
}