This week I tried to wrap my brain around working with variables. Throughout the process of creating this sketch, I realized that I was much more comfortable dealing with specificity (and words); learning to assign variables to the values and coordinates – all the math I had worked on last week – was difficult at first but gave me much more control over my code after I got the gist of it.

I discovered that variables are quite powerful in code; they offer possibilities for both repetition and change, and they can also make the act of writing code less cumbersome and time-consuming.

I chose to recreate my first sketch in p5.js using variables to see if I could add elements of chance and replication into code (Judd also experimented with these modes or extremes). Since the structure is mostly symmetrical and grid-like, composed of 25 rectangles or panels, I could create variables for each “box.”

let colorArray = [];
let leftScrew = 60;
let rightScrew = 170;
let boxWidth = 130;
let boxHeight = 30;
let firstLoad = true;

Instead of individually calculating the position of each panel, as well as the tiny screws, I could use variables to do this…magic. While Judd carefully selected and aligned the colors from the RAL color chart in his sculpture, I decided to randomize the colors of the boxes when one clicks on the mouse. Having recently dived into interaction in p5.js, I used the mouseIsPressed function to create this effect.

Link to Sketch in p5.js* Web Editor

Questions + Ideas for Class 3

How might I add a moving element (controlled independently of the mouse) to this sketch without overriding the object? I tried to insert a black square and blue triangle (with the idea that they would float across the drawing) but some parts of the object (specifically the quads, and the strokes), were layered above the shapes. I experimented with moving the layers around (e.g. background etc.) but this did not work!

Also, immense thanks to David Currie for tireless pep talks and pointers this week re: coding. It was a long week and I wish I was able to do more with this sketch, but I look forward to manipulating it more…

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s