Project 5: Wallpaper

Shirley P5

sketch
//Xinyi Du 
//15104 Section B
//xinyidu@andrew.cmu.edu
//Project-05

var w = 100; 
var h = 100;


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

function draw() {
    background(0, 58, 100);

    for (var col=0; col<3; col++) {
        for (var row=0; row<10; row++) {
            stroke(200, 223, 82); //green
            rotateEllipsee(w+3*w*col, h-100+h*row);
            stroke(221,160,221); //pink
            fill(221-90,160-90,221-90); //pink
            circleLine2(w+3*w*col, h-100+h*row);
        }
    }
    for (var col=0; col<3; col++) {
        for (var row=0; row<10; row++) {
            stroke(221,160,221); //pink
            rotateEllipsee(w+100+3*w*col, 0+h*row);
            stroke(200, 223, 82); //green
            fill(200-90, 223-90, 82-90); //green
            circleLine2(w+100+3*w*col, 0+h*row);   
        }
    }
    for (var col=0; col<3; col++) {
        for (var row=0; row<10; row++) {
            stroke(200, 223, 82); //green
            circless(-20+3*w*col, h/2+h*row);
            stroke(221,160,221); //pink
            circless(20+3*w*col, -50+h/2+h*row);
        }
    }
    
}

//draw the small circles and lines
function circleLine(x, y) {
    strokeWeight(1.5);
    push();
    translate(x, y); 
    line(60/2-5, 0, 60/2+20*sqrt(2), 0); 
    ellipse(60/2+20*sqrt(2)-10/2, 0, 10, 10);
    rotate(radians(25)); //rotate to get the second pair of ellipse and line 25 degrees above
    line(60/2-5, 0, 60/2+20*sqrt(2)-5, 0); 
    ellipse(60/2+20*sqrt(2)-10/2-5, 0, 10, 10);
    rotate(radians(-50)); //rotate to get the third pair of ellipse and line 25 degrees below
    line(60/2-5, 0, 60/2+20*sqrt(2)-5, 0); 
    ellipse(60/2+20*sqrt(2)-10/2-5, 0, 10, 10);
    pop();
}

//draw the ellipses center on (x,y)
function ellipsee(x, y) {
    strokeWeight(1.5);
    //mirror the small circles and lines though rotating them 18 degrees
    circleLine(x, y); 
    push();
    translate(x, y);
    rotate(radians(180));
    circleLine(0, 0);
    pop();

    //white ellipses
    fill(0, 58, 100);
    ellipse(x, y, 60, 39);
    ellipse(x, y, 40, 26);
    ellipse(x, y, 20, 13);
}

//roatate the ellipses drawn in the previous function
function rotateEllipsee(x, y) { 
    fill(0, 58, 100);
    push();
    translate(x, y);
    rotate(radians(-45));//rotate -45 degrees
    ellipsee(0, 0);
    pop();
}

//draw the vertical lines and circles
function circleLine2(x, y) {
    strokeWeight(2);
    //fill(221,160,221);
    line(x, y-w, x, y-w+50);
    line(x, y-w+50, x, y-w+50+h);
    line(x, y-w+50+h, x, y-w+50+h+50);
    ellipse(x, y-w+50, 12);
    ellipse(x, y-w+50+h, 12);
}

//draw the vertical circles
function circless(x, y) {
    strokeWeight(1.5);
    noFill();
    ellipse(x, y, 25);
    ellipse(x, y, 10);
    ellipse(x, y-25, 7);
    ellipse(x, y+25, 7);
    ellipse(x, y-42, 7);
    ellipse(x, y+42, 7);
}

    





Leave a Reply