Week 2 Tutorial Sketch

Re-run it to see the colors change in a gradient sequence from the left to the right in an allocated space within the size of the image.

  • Show Sketch
/**@peep sketchcode */
 
 
 
//working area
size(500, 500);
 
//random colour background
int r = random(50, 200);
int g = random(50, 200);
int b = random(50, 200);
int w = random(200, 50);
int e = random(200, 50);
int s = random(200, 50);
 
background(r, g, b);
 
//max radius value
int maxRad = 50;
//set max circles 
int maxCircles = 30;
//loop of circles first line
for(int i = 0; i < maxCircles; i++)
{
  int rad = random(20, maxRad);
  int x = random(-rad/2, 125);
  int y = random(-rad/2, 500);
  fill(w+50, e+50, s+50);
  strokeWeight(3);
  ellipse(x, y, rad, rad);
}
//loop of circles second line
//max radius value
int maxRad = 50;
//set max circles 
int maxCircles = 100;
 
for(int i = 0; i < maxCircles; i++)
{
  int rad = random(20, maxRad);
  int x = random(125, 250);
  int y = random(-rad/2, 500);
  fill(w+25, e+25, s+25);
  ellipse(x, y, rad, rad);
}
//loop of circles third line
//max radius value
int maxRad = 50;
//set max circles 
int maxCircles = 100;
for(int i = 0; i < maxCircles; i++)
{
  int rad = random(20, maxRad);
  int x = random(250, 375);
  int y = random(-rad/2, 500);
  fill(w, e, s);
  ellipse(x, y, rad, rad);
}
//loop of circles fourth line
//max radius value
int maxRad = 50;
//set max circles 
int maxCircles = 100;
for(int i = 0; i < maxCircles; i++)
{
  int rad = random(20, maxRad);
  int x = random(375, 500);
  int y = random(-rad/2, 500);
  fill(w-25, e-25, s-25);
  ellipse(x, y, rad, rad);
}