Assignment 3 – “welcome to fish school!”

Concept

So, my concept was primarily inspired by Coding Train’s video on the starfield. Initially, it was just a practice video for me to learn how to create a starfield. As I worked on it, I came across other starfield videos, such as the one by Barney Codes, which helped me understand the intricacies and complex techniques involved in creating a starfield. These techniques included pushing and popping elements from arrays, using velocity increments, and adjusting background opacity to achieve the famous trail effect.

To add a unique twist to the concept, I decided to make the movement more angular and dependent on the mouse, introducing interactivity. This led to the idea of creating a generative art piece resembling a school of fish, where the movement of the mouse also influences the way the fish move.

Fish School

The code that I am most proud of is the way I added angular movement to the “fish trail”. Despite not having done math in a while, I refreshed my knowledge of trigonometry before experimenting with the arctan function and mouse coordinates (mouseX/Y) to create dynamic angles between the origin, previous position, and current position. This resulted in a fish-like movement that works well when moving the mouse around.

// for more dynamic angular movement of fish i.e velx vely and the inverse tan function with mouseX and mouseY values
    this.velx = map(mouseX,0, width, 0,5)
    this.vely = map(mouseY,0,height,-3,5)
    
    this.vel = createVector(this.velx, this.vely);
    
    this.ang = atan2(y - (mouseY/2), x - (mouseX/2) );

 

Reflection:

I feel more confident in using mathematical functions and coding with p5.js in general. I’ve realized that it’s not always necessary to start from scratch when writing code. Instead, I can be inspired by existing functions, adapt them for my own use case, and come up with new concepts. Even the more challenging math aspects can be intimidating at first, but once I figure out an equation, it becomes enjoyable to tweak and play with the values. Sometimes, I don’t even know where the project will end up, which adds to the fun. As for the project itself, I plan to find a way to give the initial screen a fish-like quality from the beginning, rather than it only appearing once mouse movement starts. Currently, it looks like a regular starfield until then, which can be jarring.

Leave a Reply