Grid of Stars

by Matthew Chensee
  • Show Sketch
/** @peep sketchcode **/
 
size(200, 200);
background(204);
strokeWeight(4);
 
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);
}
 
void draw() {
  background(204);
  strokeWeight(4);
  for (int i=10; i < width; i+=20){
    for (int j=10; j < height; j+=20) {
     star(i,j,5,25);
  }
}
}

Comments

Nobody has said anything yet.