Project-03: Dynamic Drawing

sketch
var angle = 0;
function setup() {
    createCanvas(600, 450);
    rectMode(CENTER);
}

function draw() {
    background(0);
    fill(255, 255, mouseY);
    // restrict mouseX to 0-400
    var m = max(min(mouseX, 400), 0);
    var size = m * 350.0 / 400.0;
    if (mouseX < width/2) {
        push(); 
        translate(150,200);
        rotate(radians(angle)); 
        rectMode(CENTER);
        rect(10 + m * 190.0 / 400.0, 200.0,
         size, size);
        pop();
        angle += 5;
} 

    else {
        rect(10 + m * 190.0 / 400.0, 200.0,
         size, size);
}

    fill(mouseX, 0, 255);
    size = 350 - size;
    rect(200 + m * 190.0 / 400.0, 200.0,
         size, size);


// } else if (mouseX > width/2) {background (0,0,200)}

}

Leave a Reply