week5 tut­o­r­i­a­l­7

by yuling dong
  • Show Sketch
/** @peep sketchcode */
// karen
void setup(){ 
size(300, 400);
background(219,206,255);
stroke(116,25,122,100); // stroke color
strokeWeight(3);
 
fill(219,255,255);  //blue star
star(100, 100, 150, 250);
 
fill(255,247,149); // yellow star
star(100, 180, 20, 30);
star(180, 60, 17, 40);
star(120, 190, 20, 30);
star(200, 70, 17, 40);
star(140, 200, 20, 30);
star(220, 80, 17, 40);
star(140, 200, 20, 30);
star(220, 80, 17, 40);
star(160, 210, 20, 30);
star(240, 90, 17, 40);
star(180, 220, 20, 30);
star(260, 100, 17, 40);
star(200, 230, 20, 30);
star(280, 110, 17, 40);
star(220, 240, 20, 30);
star(300, 120, 17, 40);
}
void star(float x, float y, float inner, float outer) {
  // Define some variables to use to draw a star
  int points = 5;
  // Draw the star shape... 
  beginShape();
  float delta = radians(360/points);
  for (int i = 0; i < points; i++) {
    // Draw the outer point
    float ox = x + outer * cos(i*delta);
    float oy = y + outer * sin(i*delta);
    vertex(ox, oy);
    // Draw the inner point
    float ix = x + inner * cos(i*delta + delta/2);
    float iy = y + inner * sin(i*delta + delta/2);
    vertex(ix, iy);
  }
  endShape(CLOSE);
}

Comments

Nobody has said anything yet.