2001: A p5.js Odyssey

Computation & You!

How does computation apply to my interests? Well that’s….hm. The word computation in and of itself is one that I just struggle to wrap my head around. It’s like an idiom that I know in context but I struggle with in practice, sort of like, “A bird in the hand is worth two in the bush”. Well, I guess I don’t know what that really means either. Yet when I think of my interests – acting, sports, videogames, music – I can think of many ways in which computation applies. I would love to peel back the curtain in front of video games and see how they’re made, would love to sift through the bevy of data baseball annually spews out and make firm sense of it, would love to make an algorithm that shows just why Nina Simone gets me the way she does.

I think, above all though, computation applies to my interests because it provides an exciting new framework in which story can be told. Videogames, baseball, acting, it all comes down to story, doesn’t it? I’m reading this book by Jaron Lanier right now and in it he introduced me to the work of Karl Popper. Popper posits (lovely alliteration there; hope you said it out loud like I did) that science never achieves absolute, eternal truth, but instead gets closer and closer to truth by disqualifying false ideas. Computation provides a means to achieve a new truth in story and while that doesn’t disqualify other storytelling mediums, it does provide an exciting new tool of expression.

Karl Popper learning to code

My Sketch

 

My image is based off of a poster for the film 2001 A Space Odyssey – a favorite of mine. Originally, I was going to do my best to create the exact same image but I wanted a little bit more of a challenge so I decided to replace the walking stickman with a version of Hal based on a different 2001 poster. Eager to put a little bit of my own touch on it, I thought it would be cool to create the illusion of planets aligning above the obelisk. This is mostly where I ran into trouble.

Originally, I wanted a few of the planets to appear as if they were being eclipsed but I couldn’t figure out how to properly overlay two circles on top of one another to create that illusion. A classmate of mine, Michael Kriphack, gave me a quick and helpful lesson, reinforcing the order of operations. The issue ultimately ended up being resolved thanks to the push() and pop() functions and a great web editor that made the guessing game of where things should go far less laborious than it was with the downloadable p5 editor. In an ideal world, I would have loved for the planets to start off farther left and orbit around the center of the image, coming to a rest above the obelisk. Despite a few Google searches and some hard digging through the p5.Js reference library, I couldn’t figure out how to do this. Below is my code.

function setup() {
createCanvas(400, 400);
background(0);

//smallplanet
strokeWeight(3);
fill(250,250,0);
ellipse(196,28,75,45);

//mediumplanet
fill(250,200,0);
ellipse(198,50,90,65);

//largeplanet
fill(250,100,0);
ellipse(200,75,100,75);

//MainRectangle
fill(255);
rect(137.5,75,125,275);

//TopRectangle
strokeWeight(3);
rect(150,90,100,15);

//centercircle
fill(20,0,0);
ellipse(200,230,100,100);

fill(255,0,0);
ellipse(200,230,95,95);

fill(255,75,0);
ellipse(200,230,70,70);

fill(255,125,0);
ellipse(200,230,50,50);

fill(255,155,0);
ellipse(200,230,30,30);

fill(255,75,0);
ellipse(200,230,20,20);

fill(255,75,0);
ellipse(200,230,15,15);

//bottom line
strokeWeight(5);
line(139,310,260,310);

}

function draw() {

}

Leave a Reply

Your email address will not be published. Required fields are marked *