Arrays & Objects

We were asked to create a sketch using arrays and constructor functions. This really helped to simplify and organize the code which I appreciate, because it makes it easier to read.  For this assignment, I wanted to simply try to emulate my favourite season by making the leaves fall on the page when one clicks on the canvas. Go ahead, click above! You can also see the code here.

A struggle that I had creating this sketch was that I was trying to attempt to have the leaves fall and spin at different speeds.  This turned out to be a very daunting task and I decided I would leave that out and ask the teacher for assistance on this during class.

Last Friday, we took at stab at combining ICM with Physical computing by using serial communication to communicate between p5.js and the Arduino.  Please read about that experience at my Synthesis Workshop - Combing PComp and ICM blog post.

Re-working the fire fox

For this assignment we were asked to take an existing project to re-work and clean up the code using functions, objects and arrays -- I selected my fire fox sketch. The purpose of using functions is to compartmentalize and simplify the code.

By creating a fox function() that called all of the arguments needed to construct the fox, I am not able to easily change the following:

  1. the x, y coordinates of the fox without having to move each shape individually
  2. create multiple foxes as seen in the image below
  3. add variation to the additional fox without affecting the original fox

Here is the location to view the code for the fire fox.

I definitely see the benefit of using functions however this assignment turned out to be a lot more difficult that initially expected.  For some reason, the way functions work doesn't come easily and so this sketch rework took me quite a long time. I am going to take more time this weekend to understand the basic principles.

One specific issue that I was having was that if you have a variable in the header that references random(), it breaks the code.  For a very long time I didn't understand what was going on.  Apparently, you need to call the random() in the setup() or draw() and not in the header because random() is a specific function to p5.js and the library needs to be referenced before this can be called (?).

 

Movement in Sketch

In class two of ICM, we were asked to add movement to our sketches to an interactive component. The sketch was to include all the following elements:

  • One element controlled by the mouse.
  • One element that changes over time, independently of the mouse.
  • One element that is different every time you run the sketch.

Here is my sketch called Horus. Feel free to interact and click on the canvas

Here is the code associated with the sketch:

psych-horus-code

I was interested in trying to apply a sinusoidal waveform equation to an interactive image to see what could be created with this.  My partner has a signal processing background so he helped me through the logic of those calculations. The sine wave equation was taken from is location and iterated on to achieve the desired effect.

I wanted to create something that initially had a smooth and calming state that could be disrupted by a mouseClicked to transform to an opposing state. The hectic-ness of the quick sinusoidal wave can then be jolted back to a smooth and appealing visual with a second mouseClicked.

There is a time-based element included in this sketch where the strokeWeight continually grows over time to the height and width of the canvas an then resets to the the size of the ellipse created.

The element that is constantly random is the color associated with the ellipse that is constantly generated.

Working through the logic of movement with the application of math is an intriguing concept that I am eager to continue to explore.