For my project, I decided to add an element of interactivity. I was inspired by the visuals that were posted. I initially intended to make an “experience”, where I could use randomized texts to create unique shapes, however, I decided to create a simple blackboard instead. The idea had initialized in the library rooms, where my friends and I were studying for Calculus. My peer started writing on the whiteboard, and he had to keep on erasing previous work to progress further, when I wondered “what if we had a digital white board? One that erases on command?”
//if pixel is active, check how long it's been active if (pixels[i][j] > 0) { //stay white for 2 seconds if (millis() - pixels[i][j] < 2000) { fill(255); } else { //time expired pixels[i][j] = 0; fill(0); } } else { //default state is black fill(0); }
I am especially proud of this part of my code. It took me 5 hours just skimming through pages and brain-numbingly consuming youtube videos to figure out how to make my pixels change colour and stay and go back to default.
//on left mouse press, activate the pixel under the cursor if (mouseIsPressed && mouseButton === LEFT) { //convert mouse position to grid coords let i = floor(mouseX / pixelSize); let j = floor(mouseY / pixelSize); //only update if inside the canvas if (i >= 0 && i < cols && j >= 0 && j < rows) { //store the activation time pixels[i][j] = millis(); } } }
I also enjoyed programming this part of m code, where I had to find the location of the cursor and change the pixel colour.
Overall, I think I incorporated the loops smoothly into my project, however, I wanted to integrate a “menu bar”, with and eraser and a pen colour. I hope to involve more complex interactions in my upcoming assignments.