Jenni Lee — Project 05 — Wallpaper

sketch

/* Jenni Lee
Section E
jennife5@andrew.cmu.edu
Project- 05
*/

function setup() {
  createCanvas(480, 480);
  noLoop();
}

function draw() {
  background(234, 228, 237);
  var i, j, num;
  var distF = 75; // distance between two flowers (center)
  var numY = 7, numX = 6; // number of flower to draw on x- and y- dimension
  var r, g, b;
  for (j = 0; j < numY; j++) { // use nested for loop to draw 
    //flowers on both horizontal and vertical directions
    if (j % 2 == 0) { // even row, draw numX of flowers with one color
      num = numX;
      r = 169;
      g = 132;
      b = 173;
    } 
    else { // odd row, draw numX-1 flowers, and different color
      num = numX - 1;
      r = 163;
      g = 62;
      b = 103;
    }
    for (i = 0; i < num; i++) {
      var py = 40 + j * distF * sqrt(3) / 2; // vertical distance between 
      //two flowers is sqrt(3)/2
      var px;
      if (j % 2 == 0) { // even row - start with default position
        px = 50 + i * distF;
      } 
      else {
        px = 50 + distF/2 + i * distF; // else, indent the flower 
        //by distance/2 (distF is the distance between two flowers)
      }
      push(); // remember the state
      drawFlower(px, py, r, g, b);
      pop();
    }
  }
}

function drawFlower(x, y, r, g, b) {
  fill(r, g, b, 127); // fill in the color of the flower, 
  //plus transparency for effects

  translate(x, y);
  noStroke();
  ellipseMode(CENTER);

  for (var i = 0; i < 10; i++) { // draw ellipse 10 times, each time 
    //rotate by 36 degrees to create flower
    ellipse(0, 20, 13, 35);
    rotate(PI / 5);
  }
}

For my wallpaper project, I was inspired by my current design studio poster project which involves many flower illustrations. I found this wallpaper project to be a fun extension of Assignment B, as I extracted the element of nested for loops and combined it with the usage of ellipse rotations in order to personalize the drawing. This project was a thorough learning experience, as it allowed me to apply newly learned topics into my own projects.

Leave a Reply