For the second half of my midterm I expanded the sunflower to try and make it more interactive and a more neat / efficient piece of coding.
After a helpful adjustment from Scott, I tried to look back in the code I had written and see what changes I could make to clean up before adding more.
I organised parts of the sketch into methods that would allow me to see how the sketch plays out in a condensed layout before adding anything more.
With everything sorted I outlined the new techniques that I wanted to implement into the sketch: Arrays and a Slider.
I thought it would be cool to make the background change with the slider slightly more interesting by adding randomly generated stars in the background to complement the dark “sky”. I did this by taking and modifying the “ball” Array from class into creating smaller ellipses that would be always present, but only appear when the slider changed the background from white to black.
The next stage that was more difficult came with realising that with the slider changing the background color, the function kept redrawing over the rotating triangles meaning that original two would only appear – destroying the earlier illusion of a spinning sunflower/pinwheel. I then decided to try using an Array to generate the petals around the center of the sunflower. I found that by incrementing the starting point of rotation for each triangle generated by the array, the effect would be visible again.
The only recurring issue I had was that I previously used “mouseX” to change the shade of yellow according to the mouse position. However after using the petal Class, the same function doesn’t yield that result.