simple work of art

This week’s assignment was to make a simple work of art using loops.

I wanted to create a piece that looked like fish swimming in a pond, and the time of day changes (the color of the water shows this) when you click the ‘d’ key (d for daytime).

It doesn’t stay that way unless you keep the key pressed though.

PROCESS:

I started my code with the base sketch, and I set the size and frame rate in void setup.

In void draw, I started by setting the background color, stroke and creating a float variable col.

The col variable is a random number from 100-255. I use this later for the color of the fishes in the pond.

Next, I added the code for the ‘d’ key. When the d key is pressed, the background color changes to a lighter one, making it look like daytime.

Next, I made a for loop for the water ripples. I set an int I to zero, and it keeps increasing by one when i<100. I set the stroke of this to :
stroke(40,106,245,col)
which is a blue color, but the transparency changes to make it look like light it reflecting on the surface of the water.

Next were the fishes. I changed the fill here to:
fill(col,col-50,col-70,150)
so that the color is a random orangey-red color.

I made another for loop for the fishes, made more float variables to make random x and y values, then I made ellipses for the fish.

And that’s it! TA-DA!

CODE:

void setup(){
  size(640,480);
  frameRate(3);
}

void draw(){
  background (59,58,152);
  stroke(10);
     float col = random(100,255);
     // gives a random color 
 
    if (keyPressed && key == 'd') {
      background(152, 208, 255);  
      fill(col,col); 
    stroke(255,col);
    //else fill(col,col,0,150);
    
    // if you press the 'd' key (d= daytime) the colors change to make it look
    //like the sky during the day. 
  }
 
  for( int i = 0; i< 100; i= i+1 ) { 
 noFill();
 stroke(40,106,245,col);
 // added col here to make it look like the water is reflecting
    ellipse(width/2, height/2, i*10, i*10);
  }
  // this makes the ripple effect thing
  fill(col,col-50,col-70,150);
  //so that the color is a random orangey-red color 
  noStroke();
  for( int i = 0; i< 600; i= i+10 ) { 
   // rectMode(CENTER);
    float x = random(width);
    float y = random(height);
 
   ellipse(x,y, 25,10);
     //triangle(x,y,x,y,x,y); (triangles look more like fishes but it doesnt work properly so.. circles it is)
  
  }

}

 

Leave a Reply