Project 5: Wallpaper

sketch
/*
Bon Bhakdibhumi
bbhakdib
Section D
*/
function setup() {
    createCanvas(600, 600);
    text("p5.js vers 0.9.0 test.", 10, 15);
    background(146, 214, 255);
}

function draw() {
    // odd columns
    for(var i=50; i<=600;i+=200){
        for(var j=50; j<=600;j+=100){
            push();
            translate(i,j);
            carpattern();
            pop();
        }
    }
  // even columns
    for(var k=150; k<=600;k+=200){
        for(var l=0; l<=600;l+=100){
            push();
            translate(k,l);
            carpattern();
            pop();
        }
    }
}
function carpattern(){
    noStroke();
    // front window
    fill(195, 244, 266);
    quad(-15, -1, -17, -2, -6, -9, -5, -8);
    // car body
    fill(248, 95, 120);
    rect(-36, 2, 78, 4);
    fill(237, 67, 80);
    rect(-36, 6, 78, 5);
    fill(255, 33, 49);
    rect(29, 5, 13, 4);
    quad(42, 5, 42, 9, 44, 8, 44, 5);
    quad(-38, 6, -39, 9, -30, 9, -30, 6);
    quad(-30, 9, -30, 11, -36, 11, -38, 9);
    fill(248, 95, 102);
    rect(-15, -2, 57, 8);
    quad(-14, 6, -36, 6, -37, -2, -15, -4);
    rect(-15, 2, 57, 8);
    quad(-18, 1, -5, -9, 20, -10, 33, -1);
    // windows
    fill(195, 244, 266);
    quad(-12, 0, -3, -9, 19, -9, 26, 0);
    // black line separating the window
    fill(0);
    quad(6, 0, 8, -9, 10, -9, 10, 0);
    fill(120, 0, 3);
    rect(-20, 10, 40, 2);
    // tires
    fill(0);
    ellipse(-25, 10, 12, 12);
    ellipse(25, 10, 12, 12);
    fill(151, 162, 168);
    ellipse(-25, 10, 8, 8);
    ellipse(25, 10, 8, 8);
    // lights
    fill(247, 109, 49);
    rect(41, 1, 1, 2);
    quad(-37, 4, -38, 2, -36, 2, -36, 4);
}

I started by sketching my car in illustrator before calculating the coordinates for the geometric shapes in my canvas.

This is the reference of the car:

A BMW E30

Leave a Reply