ICM Week 4

For this week, I focused on creating a sketch that would use functions to help organize my code and cut down on repetition. My sketch is below, and the full code is available here.

At the beginning, I created a gradient. I discovered the lerpColor() function, which could interpolate colors between two chosen colors. I made the following code to create the gradient look for my water. The more "layers" that are added created a more smooth gradient as shown in the gif below.

Then I made a function to draw a fish where the arguments allowed me to position the fish, pick its color, and scale it.

I also created a function that would allow different parts of my drawing to continually loop across the screen. I made one to loop in the x direction and another to loop in the y direction. I applied this to my fish and also some bubbles I added (with functions!)

I added a function to draw a jellyfish, which was similar to the function to draw a fish, to make it more interesting. I did not like how many times I called the different functions. This is what a lot of the code in my draw() function looked like.

Is there a way to maybe store the info (position, scale, color) in another location and then call the fish() function using a loop to create many fish? Is this what arrays will help me do? I guess I will find out when I go to class and watch the rest of the Coding Train videos.