top of page
  • Writer's pictureKJ Ha

Nature of Code: 1st Assignment

Code


I first intended to create a random walker whose color is also constantly changing. I've used the millis() function to set an interval for the random color change as shown below.



// interval = 2 seconds
var fadeTime = millis();
if (millis() - timeOfLastSwitch > interval) {
    dotColor = color(random(0, 255), random(0, 255), random(0, 255));
    timeOfLastSwitch = millis();
}
    

To give the user more freedom, I set the mousePressed function where the user's mouse click can relocate the starting point of the random walker. The user may press the escape key to clear the canvas.



Live Sketch




Demo Video



Recent Posts

See All

Link to video recording: https://youtu.be/_n7wWtambYc For the final, I would like to continue working on the mid-semester exercise. (link to mid-semester exercise: https://editor.p5js.org/kh1785/sketc

bottom of page