This week we were asked to create a sketch that includes:

  • Reorganize “groups of variables” into objects.
  • Break code out of setup() and draw() into functions.
  • Use a function to draw a complex design multiple times with different arguments.
  • Embedding a function into an object.

I created each creature as a function which included the creature’s eyes as  objects.

In addition I defined a “drop” function which embedded a create function:

var drop = {
x: random(width),
y: random(-40, height),
speed: 0,
length: random(30, 40),
create: function() {
stroke(200, random(200, 255), random(100, 255));
line(drop.x, drop.y, drop.x, drop.y + drop.length);

All the “new” functions were coded out of the setup() and draw() functions.


A Question:

  • Why this is a valid variable

x: random(width),

but this isn’t?
l: line(drop.x, drop.y, drop.x, drop.y + drop.length);
both are functions of P.5


Categories: Computational Media

Leave a Reply

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