Charmaine Qiu – Project 05 – Wall Paper

sketch

/*  Charmaine Qiu
    charmaiq@andrew.cmu.edu
    Section E
    Wall Paper */


var spacing = 10;

function setup() {
    createCanvas(600, 600);
}

function draw() {
    background(240, 182, 127);
    //nested loop that loops over rows and columns of pattern
    for(var y = 0; y <= height; y += spacing){
      for(var x = 0; x <= width; x += spacing){
        //call wallPaper that draws the shapes
        wallPaper(x, y);
      }
    }
    noLoop();
}

//create a funtion for the patterns that follow the nested for loop
function wallPaper(x, y){
  //set variable of sides of rectangles that becomes bigger as it goes up canvas
    var rectspc = y / 80
  //lightest teal rectangles
    fill(214, 229, 227);
    noStroke();
    rect(x + spacing / 2, y, rectspc, rectspc);

  //3rd lightest teal rectangles
    fill(104, 216, 214);
    noStroke();
    rect(x, y, rectspc, rectspc);
  //2nd lightest teal rectangles
    fill(156, 234, 239);
    noStroke();
    rect(x + spacing / 2, y +spacing / 2, rectspc, rectspc);
  //darkest teal rectangles
    fill(7, 190, 184);
    noStroke();
    rect(x , y +spacing / 2, rectspc, rectspc);
}

Through this project, I learned to organize my code in a more efficient way by creating a new function and calling it in function draw.It was a fun experience to create my own systematic pattern and assigning colors to them.

Leave a Reply