User Input Visuals in Processing - Malakai Linden

int dotSize = 10;
int dotPulse = 0;
int m = minute();

void setup() {
size(displayWidth, displayHeight, P3D);
background(#000000);


}

//——————————————————————

void draw() {
int dotPulse = 0;

doStuff(); // Does stuff in “BRAIN” tab. See “BRAIN” for controls.

}

//——————————————————————

void doStuff() { // Program instructions

background(#000000); // Sets background black.
if (key == ‘d’) { // If ‘d’ key, draws grid of dots. Move mouse to change colors. background black.
bDots();
}
if (key == ‘s’) { // If ‘s’ key, draws grid of dots. Move mouse to change colors. background white
wDots();
}
if (key == ‘b’) { // If ‘b’ key is pressed, draws vertical bars. Move mouse side to side to change width of bars.
bars();
}

}

//——————————————————————

// Draws vertical bars
void bars() {
for (int x = 0; x < displayWidth; x = x+1) {
fill(random(0, 100), random(0, 255), random(0, 255));
translate(x, 0, 0);
rect(0, 0, map(mouseX, 0, width, 0, 20), height);
}

if (mousePressed) {
background(#FFFFFF);
}
}

//——————————————————————

// Draws dots with black background. mouse x/y change color.

void bDots() {
background(#000000);
for (int x = 20; x < displayWidth-10; x = x+20) {
for (int y = 20; y < displayHeight-10; y = y+20) {
lights();
directionalLight(100, 200, 225, 1, -1, 2);
ambientLight(map(mouseX, 0, width, 0, 255), random(50, 200), map(mouseY, 0, height, 0, 255));
ambient(random(100, 255));
if (mousePressed) {
dotPulse = 5;
}
else {
dotPulse = 0;
}
ball(x, y, dotSize + dotPulse);
}
}
}


//——————————————————————

// Draws grid of white circles w/ ambient light. White background.
void wDots() {
background(#FFFFFF);
for (int x = 20; x < displayWidth-10; x = x+20) {
for (int y = 20; y < displayHeight-10; y = y+20) {
lights();
directionalLight(255, 225, 225, 0, 0, 0);
ambientLight(map(mouseX, 0, width, 0, 255), map(mouseY, 0, height, 0, 255), random(50, 200));
ambient(random(0, 170));
if (mousePressed) {
dotPulse = 5;
}
else {
dotPulse = 0;
}
ball(x, y, dotSize + dotPulse);
}
}
}

//——————————————————————

// Draws white circle at coordinates specified by xPos/yPos.
void ball(int xPos, int yPos, int dotSize) {
smooth(8);
fill(#FFFFFF);
noStroke();
ellipse(xPos, yPos, dotSize, dotSize); // Size of sphere
}

adambassiouni8