lee chu – project 05 – wallpaper

lrchu

// lee chu
// section c
// lrchu@andrew.cmu.edu
// project - 05


var spacing;
var size;
var raus;
var x;
var y;

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

    spacing = 150;
    size = 21;
}

function draw() {
    background(249, 246, 219);
    polkadots();
    for (var y = 0; y <= height; y += spacing / 2) {
        if ((y / spacing / 2 * 4) % 2 == 0) {
            for (var x = 0; x <= width; x += spacing) {
                rose(x, y, 1);
            }
        }
        else {
            for (var x = spacing / 2; x <= 3.5 * spacing; x += spacing) {
                rose(x, y, 0);
            }
        }  
    }
}

function polkadots() {
    for (var x = 0; x <= width; x += spacing / 2) {
        for (var y = 0; y <= height; y += spacing / 2) {
            strokeWeight(0);
            fill(168, 218, 220);
            ellipse(x, y, 8, 8);
        }
    }
    /*
    x = 0;
    y = 0;
    */
}

function rose(a, b, raus) {
    // leaves
    fill(26, 158, 81);
    beginShape();
    vertex(a, b);
    bezierVertex(a - 0.5 * size, b - 0.25 * size, a - 0.5 * size, b, a - 0.75 * size, 
    b + 0.5 * size);
    endShape();
    beginShape();
    vertex(a, b);
    bezierVertex(a + 0.5 * size, b - 0.25 * size, a + 0.5 * size, b, a + 0.75 * size, 
    b + 0.5 * size);
    endShape();

    // red
    if (raus == 0) {
        fill(107, 39, 55);
    }

    // blue
    else {
        fill(0, 57, 119);
    }

    // flower
    push();
    translate(a, b - 5);
    rotate(PI/4);
    for (h = 0; h < PI; h += PI / 8) {
        ellipse(0, 0, 28, 6);
        rotate(h);
    }
    fill(249, 246, 219);
    ellipse(0, 0, 4, 6);
    pop();
}

I wanted to create a simple floral repeating pattern.

Leave a Reply