Project03-Dynamic Drawing

sketchDownload
var R=255;
var G=153;
var B=203;
var x=380;
var y=280;

function setup(){
    createCanvas(600, 450);
    background(0);
}

function draw() {
    background(0);
    stroke(0);
    line(600,0,mouseX,mouseY);
   //change angle
    var angle=mouseX;
    push();
    //change origin
    if(mouseY>225){
        translate(200,225);
    }
    else{translate(400,225);
    }
    rotate(radians(angle));
    fill(R,G,B);
    var x=mouseX;
    var y=mouseY;
    circle(x,y,200);
    circle(x+30,y-160,50);
    circle(x-160,y+30,70);
    circle(x-140,y+50,30);
    //change color
    if(mouseY<150){
        R=0,
        G=255;
        B=255;
    }
    else if(mouseY>300){
        R=255;
        G=255;
        B=102;
    }
    else{
        R=255;
        G=153;
        B=203;
    }
    //change scale
    if(mouseX<200){
        scale(0.6);
        fill(R,G,B);
        circle(x,y,300);
        circle(x+30,y-160,50);
        circle(x-160,y+30,70);
        circle(x-140,y+50,30);
    }
    else if(mouseX>400){
        scale(0.4);
        fill(R,G,B);
        circle(x,y,300);
        circle(x+30,y-160,50);
        circle(x-160,y+30,70);
        circle(x-140,y+50,30);
    }
    else{
        scale(0.2);
        fill(R,G,B);
        circle(x,y,300);
        circle(x+30,y-160,50);
        circle(x-160,y+30,70);
        circle(x-140,y+50,30);
    }
    pop();

}

When I first started this dynamic drawing, I have no idea what to do. Therefore, I simply drew 4 circles, and then changed their color, rotating position, scaling size, and rotating angle. I encountered several difficulties on making my drawing move by my logic, because I didn’t fully understand how certain function work in computer logic. As I look at detailed instructions on these function, I made it work eventually, and I had a more comprehensive understanding of these functions.

Leave a Reply