Project 04

sketch
// Sowang Kundeling skundeli Section C Project 04


function setup() {
    createCanvas(400, 300);
}

function draw() {
    background('lavender');
    noLoop();

    var x = 0;
    var y = 0;
    var x2 = 400;
    var y2 = 300;
    var numLines = 100;
    var diam;
    var d1 = 2;

    // cross shapes that make a butterfly
    stroke('teal');
    for (var i = 0; i <= numLines; i += 1) {
        line(width - i, y, x, y + i*3);
        line(i, y2, x2, y2 - i*3);
        line(width - i, y2, x, y2 - i*3);
        line(i, y, x2, y + i*3);
    }

    // circles
    noFill();
    stroke('darkblue');
    for(diam = d1; diam <= 37; diam *= 1.15) {
        ellipse(165, 30, diam, diam);
        ellipse(width - 165, 30, diam, diam);
    }

    // inside body
    stroke('lightblue');
    for (var i = 150; i <=250; i += 3) {
        line(width/2, height/3, i, height/2);
        line(width/2, height*(2/3), i, height/2);
    }

    // antenna
    stroke('darkblue');
    line(width/2, height/3.05, 165, 30);
    line(width/2, height/3.05, width-165, 30);
}

I made a butterfly!

Leave a Reply