Project 3

sketch
//Paul Li
//Section A



var backR = 10;
var backG = 10;
var backB = 10;
var w = 30;
var h = 20;
var triR = 30;
var triG = 40;
var x = 1;


function setup() {
    createCanvas(600,450);
    rectMode(CENTER);
}

function draw() {

    //background & color
    //background color changes based on mouse
        backR = max(min(mouseY/2,255),0);
        backG = max(min(mouseX/2.2,255),0);
        backB = max(min(mouseX,255),0);
        background(backR,backG,backB,mouseY/60)
    //shape & shape movement
    // stroke weight and width and height of the ellipse is determined by mouse position
    // 
        w = min(mouseY,width - 30);
        h = min(mouseX,height - 30);
        strokeWeight(mouseX/100+mouseY/100);
        stroke(backG,backR,backB);
        fill(backG,backR,backB);
        ellipse(width/2,height/2, w, h);
//triangles rotate and move according to mouse cordinates in inverse and direct relationships
        push();
        rotate(radians(min(mouseX,width)));
        fill(backB,backR,backB);
        triangle(
            constrain(mouseX/(mouseY/30),0,width),mouseY,
            constrain(mouseY/(mouseX/30),0,width-50),mouseY,
            mouseX,mouseY
            );
        pop();
// chnaging color by mouse position.
        push();
        triR = constrain(mouseX,0,width);
        triG = constrain(mouseY, 0, height);
        translate(width/2,height/2);
        rotate(radians(min(mouseY,height)));
        fill(triR,triG,0);
        triangle(
            constrain(mouseY/(mouseX/10),0,width),mouseY,
            constrain(mouseX/(mouseY/10),0,width-100),mouseY,
            mouseX,mouseY
            );
       
        pop();


// square in the center & moving squares.
        fill(0,0,0,60);
        stroke(backG/2,backR,backB)
        square(width/2,height/2,height/min(mouseX/100,mouseY/30));
        push();
        translate(50,50);
        rotate(radians(x));
        x+= 4;
        fill(255);
        rect(width/2,height/2,constrain(mouseX,0,100),constrain(mouseY,0,50));
        pop();

        push();
        translate(width,50);
        rotate(radians(x));
        x+=4;
        fill(255);
        rect(width/2,height/2,constrain(mouseX,0,50),constrain(mouseY,0,20));
        pop();

        strokeWeight(2);
        stroke(255-backG/2,255-backR,255-backB)
        line(mouseX,mouseY,width/2,height/2);



        //frameRate(400);


    //scaling

      //  }
   // }
}
 

Leave a Reply