Alice Cai_project03_dynamic drawing

sketch


//Alice Cai
//Section E
//alcai@andrew.cmu.edu
//Project 3

//global variables
var angle = 0


//canvas setup and original background
function setup(){
    createCanvas(640,480);
    background(220);
}

function draw() {
    stroke(mouseX, mouseY);
    strokeWeight(10);
    //color controls changes at half canvas 
    if (mouseX < width / 2){
    fill(mouseY ^ 2, mouseY ^ 2, mouseX ^ 2); 
} else {
    fill(mouseX ^ 2,mouseY ^ 2,mouseY ^ 2); 

}
    
//ellipse positioning
    push();
    translate(mouseX, mouseY);
    rotate(radians(angle) / 100);
    ellipse(0, 0, mouseX, mouseY);


    pop();
    angle = angle + mouseX;

//color controls changes at half canvas for second ellipse
    stroke(mouseX, mouseY);
    if (mouseX > width / 2){
    fill(mouseX / 5,mouseY * 3,mouseY); 
} else {
    fill(mouseX, mouseX, mouseY / 2); 
}
//ellipse2 positioning,not center of mouse, size and position is opposite of original

    push();
    translate(640 - mouseX, 480 - mouseY);
    rotate(radians(angle) / 100);
    ellipse(0, 0, mouseX, mouseY);
    pop();
    angle = angle + mouseX;
    

}

This is my dynamic drawing! It quite literally is dynamic drawing. I started this by using our lab exercises with spinning square moving with the mouse. Then, I changed it to a circle, added another circle, and offset one of them through translate. One of the circles moves opposite of the mouse. I did this by using the previous assignment, with Width/height – mouseX/mouseY. Then, I moved background to set up so that the background doesn’t reset and you can see all the circles that are drawn. The colors of the stroke weight and the circle fills are all controlled by mouseX and mouseY coordinates, as well as the speed of the spinning.

Leave a Reply