Ass­e­s­s­m­e­n­t 1

by Danielle Pontes

"Movement and Energy"

  • Show Sketch
/** @peep sketchcode */
 
//canvas size of 400x400 pixels with black background, and all shapes will have no stroke
size(400,400);
background(0); 
noStroke();
 
drawBigPlanet();      //calling function "drawBigPlanet" 
drawMediumPlanet();   //calling function "drawMediumPlanet" 
drawSmallPlanet();    //calling function "drawSmallPlanet" 
drawSmallStar();      //calling function "drawSmallStar" 
 
 
/*
function called "drawBigPlanet" that creates 3 big planets as per loop set to run 3 times
-Location is determined by random x&y coordinates between 30 and 370. 
-Diameter is determined by a random float variable d2 that ranges from 120-150. 
-Fill colors vary between blues and greens,
 as determined by random fill where red varies between 0-255, green remains at 0, and blue remains at 100.
-The circles have an opacity ranging from 47-78% as determined by randomized 4th parameter of fill().
*/
void drawBigPlanet()
{
  float d=random(120,250);        //setting random float variable for diameter outside of loop to keep diameter uniform across all 3 iterations
  for(int i=0; i<3; i++)          //loop to draw 3 ellipses
  {
    float x=random(30,370);       //setting random variable for x coordinates
    float y=random(30,370);       //setting random variable for y coordinates
    fill(random(255),0,230,random(120,175));  //setting fill color and opacity
    ellipse(x,y,d,d);             //calling command to draw ellipse
  }  
}
 
/*
function called "drawMediumPlanet" that creates 5 medium planets as per loop set to run 5 times
-Location is determined by random x&y coordinates between 30 and 370. 
-Diameter is determined by a random float variable d3 that ranges from 70-90. 
-Fill colors vary between blues and greens,
 as determined by random fill where red varies between 0-255, green remains at 0, and blue remains at 100.
-The circles have an opacity ranging from 47-78% as determined by randomized 4th parameter of fill().
*/
void drawMediumPlanet()
{
  float d3=random(70,90);         //setting random float variable for diameter outside of loop to keep diameter uniform across all 5 iterations
  for(int i=0; i<5; i++)          //loop to draw 5 ellipses
  {
  float x=random(30,370);         //setting random variable for x coordinates
  float y=random(30,370);         //setting random variable for y coordinates
  fill(random(255),100,230,random(120,175));  //setting fill color and opacity
  ellipse(x,y,d3,d3);             //calling command to draw ellipse
  }
}
 
/*
function called "drawSmallPlanet" that creates 5 small planets as per loop set to run 5 times
-Location is determined by random x&y coordinates between 30 and 370. 
-Diameter is determined by a random float variable d2 that ranges from 30-60. 
-Fill colors vary between blues and greens,
 as determined by random fill where red remains at 0, green remains at 230 and blue varies between 0-255.
-The circles have an opacity ranging from 47-78% as determined by randomized 4th parameter of fill().
*/
void drawSmallPlanet()
{
  float d2=random(30,60);       //setting random float variable for diameter outside of loop to keep diameter uniform across all 5 iterations
  for(int i=0; i<5; i++)        //loop to draw 5 ellipses
  {
  float x=random(30,370);       //setting random variable for x coordinates
  float y=random(30,370);       //setting random variable for y coordinates
  fill(0,230,random(255),random(120,175));  //setting fill color and opacity
  ellipse(x,y,d2,d2);           //calling command to draw ellipse
  }
}  
 
/*
function called "drawSmallStar" that creates 5 small stars as per loop set to run 5 times
-Location is determined by random x&y coordinates between 30 and 370. 
-size is determined by 2 set variables
-number of points is determined by random integer between 5 and 8
-Fill colors vary between blues and greens,
 as determined by random fill where red remains at 0, green remains at 230 and blue varies between 0-255.
-The stars have an opacity ranging from 47-78% as determined by randomized 4th parameter of fill().
-Code to draw basic star borrowed from Tutorial 7: Drawing with Functions, part 2:A custom drawing function
-altered with randomization and formatting
*/
void drawSmallStar() 
{
  float inner=(int)random(5,8);      //setting random distance from center point of the star to the inner points of the star ranging from 5-8
  float outer=(int)random(10,13);     //setting random distance from center point of the star to the outer points of the star ranging from 10-13
                      //these variables sit outside of the recursion loop to keep size uniform across all 5 iteratios
  for(int i=0; i<5; i++)    //loop to draw 5 stars
  {
    float x=random(30,370); //setting random variables for x and y coordinates 
    float y=random(30,370); //setting random variables for x and y coordinates 
    int p=(int)random(5,8);   //setting random variable for the amount of points the star will have. 
                              //need to create a whole number to avoid problems calculating each point's location later    
    fill(0,230,random(255),random(120,175));  //setting fill color and opacity
    beginShape();           //begin to create a shape based on vertex points 
    float delta = radians(360/p);   //setting the angle between each offshoot of the star at an equal angle depending on the amount of random points the star has
    for (int j = 0; j < p; j++)     //a loop to traverse through each point that the star will have, determinig its x and y values
    {
      float ox = x + outer * cos(j*delta);  //determines the outer x coordinates of the star
      float oy = y + outer * sin(j*delta);  //determines the outer y coordinates of the star
      vertex(ox, oy);                       //the resulting vertex will be included as a point on the shape
 
      float ix = x + inner * cos(j*delta + delta/2);      //determines the inner x coordinates of the star
      float iy = y + inner * sin(j*delta + delta/2);      //determines the inner y coordinates of the star
      vertex(ix, iy);                                     //the resulting vertex will be included as a point on the shape
    }  
    endShape(CLOSE);      //enclose area surrounded by resulting vertexes     
  }
}

Comments

Nobody has said anything yet.