• KJ 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

Nature of Code: 2nd Assignment

Code For the second assignment, I've decided to develop the first assignment further. Besides using the createVector() function, for a more dynamic visual effect, I played with the alpha value of the

© 2020 Kyungjoo Ha. All Rights Reserved