ICM Week 4: Repetition Loops

See below for UPDATED sketch info.

This week we worked with creating repetitive designs using loops.  With Dan Shiffman’s 10PRINT Sketches as inspiration, I created the following: 


Code

I wanted to add the function mousePressed() into the sketch in order for the colors and overall design to reset into a new configuration.  In order to get the functionality I desire, one will need to either (1) refresh the browser or (2) enter in the Code and press play to get a new configuration of the design.  Here is a version of the same sketch without noLoop() but with mousePressed().   I’ve set the frame rate to 1 frame per second so that the animation is not spastic.  Click within the design and you will receive a new color configuration. 

 

Code

I would like to find a way to freeze the sketch then be able to reset the colors and shape placement by pressing the mouse. 

 

UPDATE:
In class, we were shown how to achieve what I was attempting.  By adding the for loop which created the sketch into mousePressed(), I was able to have the sketch update when the mouse is pressed. 

 

Code

Leave a Reply

Your email address will not be published. Required fields are marked *