Project-03: Dynamic Drawing

sketch
var d= 100;//diameter of each circle

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

function draw() {
    background(10);
    noStroke();
    
    d=min(mouseX,width);//d changes when the mouse moves
    fill("red");
    circle(width/4, height/4, d);//top left red circle
    fill("green");
    circle((width/4)*3, (height/4)*3, d);//bottom right green circle
  
    d=width-d;// d changes oppositely 
    fill("blue");
    circle(width/4, (height/4)*3, d);//bottom left blue circle
    fill("orange");
    circle((width/4)*3, height/4, d);//top right orange circle
    
}

When I was designing the graph, I was thinking about the idea of contrasting colors (red and green, blue and orange) and circles popping out.

project 3: dynamic drawing

I really wanted to make something that incorporated color changes without using a lot of colors. So I messed around with blend modes and created this!

isis-dynamic
// isis berymon section D

var x;
var y;
var bluex;
var bluey;
var greenx;
var greeny;
var d;

function setup() {
    createCanvas(500,500);
    background(0);
    d = 100;
    bluex = width/2;
    bluey = height/2;
    greenx = width/2;
    greeny = height/2;
}

function draw() {
    blendMode(BLEND); //makes bg opaque
    background(0);
    blendMode(SCREEN); //brightens overlapping colors
    fill(255,0,0);
    circle(width/2, height/2, d);
    fill(0,255,0);
    circle(greenx, greeny, d);
    fill(0,0,255);
    circle(bluex, bluey, d);
    //diameter scales with how far mouse is from center
    d = width/2-dist(width/2, height/2, mouseX, mouseY);
    //blue circle moves opposite the mouse
    bluex = width/2 + (width/2-mouseX);
    bluey = height/2 + (height/2-mouseY);
    //green circle moves with the mouse
    greenx = width/2 + (mouseX-width/2);
    greeny = height/2 + (mouseY-height/2);
}

project 03: cube-y

the hardest part for me was sticking with an idea, and resisting the urge to scrap my code constantly. it was also tricky to keep my variables in check without rewriting them with each function… anyway, try moving your mouse around the canvas and clicking!

sketch
// Jaden Luscher
// section A
// project 03

var x = 0;
var y = 0;
var square1 = 0;
var square2 = 0;
var rot1 = 0;
var rot2 = 0;
var col = 200;

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

function draw() {
  background(200,200,100);
  rectMode(CENTER);
  noStroke();
  fill(col);
  translate(width/2, height/2); // move origin to center of canvas

  square1 = (mouseX + mouseY) / 2; // move mouse to change square size
  rot1 += 0.01; // makes square 1 spin
  rotate(rot1);
  rect(x, y, square1, square1); // center square (square 1)

  square2 = (mouseX - mouseY); // size of four squares differs from square 1
  if(mouseX > mouseY) {
    rot2 = 2 * rot1; // spins clockwise
  } else {
    rot2 = -2 * rot1; // spins counter clockwise
  }
  rotate(rot2);
  rect(x + square2, y + square2, square2, square2);
  rect(x - square2, y - square2, square2, square2);
  rect(x + square2, y - square2, square2, square2);
  rect(x - square2, y + square2, square2, square2); // four squares at corners

  if (mouseIsPressed) { // squares "jitter" & turn white
    rot1 *= -1;
    col = 255;
  } else {
    col = 0;
  }

  print("square2 = ", square2);

}

Project 03

sketchDownload
// Ilia Urgen
// Section B

var angle = 0;

var color_1;
var color_2;

var background_lines = 0;

var triangle_1 = 1;
var triangle_2 = 2;
var triangle_3 = 3;
var triangle_4 = 4;
var triangle_5 = 5;
var triangle_6 = 6;


function setup() {
    stroke (2);
    createCanvas (800, 800);
    color_1 = color (255,140,0);
    color_2 = color (63,191,191);

    for (var y = 0; y < height; y++ ) {
        n = map (y,0, height, 0, 1);
        var color_3 = lerpColor (color_1, color_2, n);
        stroke (color_3);
        line (0, y, width, y);
    }
}                                                                  
function draw() {
    
    delta_x = mouseX/6;
    delta_y = mouseY/6;

    frameRate(30);

    stroke (2);
    push();

    translate(400, 400);
    rotate(radians(angle));

    if (background_lines == 0) {
        line (0,0, width, height);
        line (width, 0, 0, height);
        angle += 25; 
    }

    if (triangle_1 == 1) {
        // changes 1st darkest color gradient
        fill (132-mouseX/4, 0, 132-mouseY/4);
        // changes thickness and width of triangle
        triangle (0,0, -(delta_x + 100), delta_y + 150, (delta_x + 100), delta_y + 150);
        angle += 5;
    }

    if (triangle_2 == 2) {
        // changes 2nd darkest color gradient
        fill (152-mouseX/4, 0, 152-mouseY/4);
        // changes thickness and width of triangle
        triangle (0,0, -(delta_x + 80), delta_y + 120, (delta_x + 80), delta_y + 120);
        angle -= 15;
    }

    if (triangle_3 == 3) {
        // changes 3rd darkest color gradient
        fill (176-mouseX/4,0,176-mouseY/4);
        // changes thickness and width of triangle
        triangle (0,0, -(delta_x + 60), delta_y + 90, (delta_x + 60), delta_y + 90);
        angle += 200;
    }

    if (triangle_4 == 4) {
        // changes 4th darkest color gradient
        fill (204-mouseX/4, 0, 204-mouseY/4);
        // changes thickness and width of triangle
        triangle (0,0, -(delta_x + 40), delta_y + 60, (delta_x + 40), delta_y + 60);
        angle -= 150;
    }
    
    if (triangle_5 == 5) {
        // changes 5th darkest color gradient
        fill (232-mouseX/4,0,232-mouseY/4);
        // changes thickness and width of triangle
        triangle (0,0, -(delta_x + 20), delta_y + 30, (delta_x + 20), delta_y + 30);
        angle += 100;
    }

    if (triangle_6 == 6) {
        // changes 6th darkest color gradient
        fill (255-mouseX/4,0,255-mouseY/4);
        // changes thickness and width of triangle
        triangle (0,0, -(delta_x), delta_y, (delta_x), delta_y);
        angle -= 55;
    }

    pop();
}

Project 3 Dynamic Drawing

The piece is inspired by 3D Glasses, and the relationship between Red and Blue light in bringing images “off the screen.” I think it has a really cool holographic affect to it that is also brought about with proximity and rotation.

HOLD DOWN ON MOUSE TO CHANGE SIZE AND COLOR

sketch

//Aarnav Patel
//Section D

var side;
var midX = 0;		//the coordinates of the middle squares (what the other squares are proportional to)
var midY = 0; 
var rotation = 0;
var color1 = 255;
var color2 = 0;


function setup() {
    createCanvas(600, 450);
    background(220);
    text("p5.js vers 0.9.0 test.", 10, 15);
    side = width / 32;	

}

function draw() {

	//change my origin to the middle of the canvas to better organize my rectangles
	translate(width / 2, height / 2);
	background(0);
	noStroke();
	colorMode(RGB);

	//side rectangles are proportionally equidistant from the middle square (based on x value)
	xdiff = min(mouseX / 2, (width / 2) - side);
	ydiff = min(mouseY / 2, (height / 2) - side);
	

	//Red Rectangles (TOP ROW)
	fill(color1, 0, color2, 100);
	push();							//Create its own coordinate system (for rotation)
	translate(midX, midY - ydiff);	//MID square coordinate place
	rotate(radians(rotation));	
	rectMode(CENTER);				//means that the x and y value below are the CENTER of the rectangle
	rect(0, 0, side, side);
	pop();							//reset coordinate sytem for next rectangle

	push();
	translate(midX - xdiff, midY - ydiff);	//LEFT square coordinate place
	rotate(radians(rotation));
	rectMode(CENTER);
	rect(0, 0, side, side);
	pop();

	push();
	translate(midX + xdiff, midY - ydiff);		//RIGHT square coordinate place
	rotate(radians(rotation));
	rectMode(CENTER);
	rect(0, 0, side, side);
	pop();

	//blue rectangles (BOTTOM ROW)
	fill(color2, 0, color1, 100);
	push();
	translate(midX, midY + ydiff);		//MID square coordinate place
	rotate(radians(rotation));
	rectMode(CENTER);
	rect(0, 0, side, side);
	pop();

	push();
	translate(midX - xdiff, midY + ydiff);		//LEFT square coordinate place
	rotate(radians(rotation));
	rectMode(CENTER);
	rect(0, 0, side, side);
	pop();

	push();
	translate(midX + xdiff, midY + ydiff);		//RIGHT square coordinate place
	rotate(radians(rotation));
	rectMode(CENTER);
	rect(0, 0, side, side);
	pop();

	rotation = rotation + 1;	//Increment rotation so squares always spinning

	
	if (mouseIsPressed) {	//if user holds mouse, it changes color (switches blue and red values of each row)
		if (color1 != 0) {
			color1 -= 1;
			color2 += 1;
		} else {
			color1 += 1;
			color2 -= 1;
		}


		if (side >= width) {	//if rectangles get too big for the canvas, it resets back to initial side length
			side = width / 32;
			color1 = 255;
			color2 = 0;
		} else {
			side = side * 1.01;
		}
	}

	

}

Project-03: Dynamic Drawing

Moving the cursor up and down can change the rotation direction of the white “flower”. Moving the cursor left and right can change the canvas color and the size of the circles. If the cursor is inside the circle, the corresponding circle will change color.

Xinyi Du

sketch
//Xinyi Du 
//15104 Section B

var w = 20;
var x1 = 150;
var y1 = 150;
var w1 = 220; 
var x2 = 400;
var y2 = 300;
var w2 = 260;
var x3 = 500;
var y3 = 75;
var w3 = 130;
var r = 30;
var g = 144;
var b = 255;
var lineY = 1000;
var angle = 10;
var dia = 15;

function setup() {
    createCanvas(600, 450);
}
 
function draw() {
    background(r, g, b);
    noStroke();
    //left circle
    r1 = 100;
    g1 = 149;
    b1 = 237;
    fill(r1, g1, b1);
    ellipse(x1, y1, w1, w1);
    // bottom circle
    r2 = 100+20;
    g2 = 149+20;
    b2 = 237+10;
    fill(r2, g2, b2);
    ellipse(x2, y2, w2, w2);
    //right circle
    r3 = 100-20;
    g3 = 149-20;
    b3 = 237-10;
    fill(r3, g3, b3);
    ellipse(x3, y3, w3, w3);

    // change mouse X to change the size fhe circles as well as the color of the canvas
    if (mouseX < width/2) {
        w1 = constrain(w1-5, 150, 400); //decrease left circle size
        w2 = constrain(w2+5, 200, 450); // increase bottom circle size
        w3 = constrain(w3-5, 80, 280); //decrease right circle size
        r = constrain(r + 0.5, 30, 60);
        g = constrain(g + 0.5, 144, 174);
        b = constrain(b + 0.5, 255, 275); // make canvas color lighter and limit the rgb range
    }

    if (mouseX > width/2){
        w1 = constrain(w1+5, 150, 400); //increase left circle size
        w2 = constrain(w2-5, 200, 450); //decrease bottom circle size
        w3 = constrain(w3+5, 80, 280); //increase right circle size
        r = constrain(r - 0.5, 5, 30);
        g = constrain(g - 0.5, 114, 144);
        b = constrain(b - 0.5, 225, 255); // make canvas color darker and limit the rgb range
    }

    // if mouse is inside the circle, change color
    if (dist(mouseX, mouseY, x1, y1)<w1/2){ 
        r1 = 195;
        g1 = 177;
        b1 = 225;
        fill(r1, g1, b1);
    //left circle
        ellipse(x1, y1, w1, w1);
        }
    if (dist(mouseX, mouseY, x2, y2)<w2/2){
        r2 = 189;
        g2 = 181;
        b2 = 213;
        fill(r2, g2, b2);
    // bottom circle
        ellipse(x2, y2, w2, w2);
        }
    if (dist(mouseX, mouseY, x3, y3)<w3/2){
        r3 = 204;
        g3 = 204;
        b3 = 255;
    //right circle
        fill(r3, g3, b3);
        ellipse(x3, y3, w3, w3);
        }

    // draw white lines and circles
    stroke(255);
    noFill();
    strokeWeight(1.2);
    ellipse(mouseX, mouseY, w+10, w+10);

    translate(mouseX, mouseY); // translate the origin from (0,0) to (mouseX, mouseY)
    line(0, 0, 0, lineY); //one line and three circles on the line
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle)); // rotate the line and repeat the process
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle)); // rotate the line and repeat the process
    line(0, 0, 0, lineY); 
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 40, dia); ellipse(0, 100, dia+10);
    rotate(radians(angle));
    line(0, 0, 0, lineY);
    ellipse(0, 60, dia); ellipse(0, 130, dia+20);ellipse(0, 200, dia+40);

    // change mouseY to change the rotating direction and rotation angles
    // if mouseY is at the bottom half of the canvas, increase the rotation angle
    if (mouseY < height/2) { 
        angle = constrain(angle + 0.5, -10, 20);
    }
    // if mouseY is at the top half of the canvas, decrease the rotation angle
    if (mouseY > height/2){
         angle = constrain(angle - 0.5, -10, 20); 
    }
}



Project-03-Dynamic-Drawing: Section B

My process for this project was to alter basic shapes and colors to create a kaleidoscope. I used transformations so I could draw the same images many times in different locations. Moving the mouse left and right shrinks, enlarges, and repositions different elements. Crossing the horizontal midpoint reverses the rotation. Vertical motion with the mouse speeds and slows the rotation. Clicking changes colors.

From my sketchbook.
sketch
// Evan Stuhlfire
// estuhlfi, section B
// Project-03: Dynamic Drawing

var angle = 0; // Angle to increment for rotation
var angleInc = 2; // Controls speed of rotation
var rotateDir = 1; // Direction of rotation
var centerX; // Center of original canvas
var centerY;
var shapeSpace = 30; // Space between shapes
var rectSize = 20;
var startSize = 10;
var circleStart = 10;
var littleCircle = 10;
var colorScheme = 1; // standard = 1, switched = -1

function setup() {
    createCanvas(600, 450);

    centerX = width/2;
    centerY = height/2;
}

function draw() {
    background(50);

    // If the mouse is left of center set rotation counterclockwise
    if(mouseX < centerX){
        rotateDir = -1;
    } else {
        rotateDir = 1; // Set rotation clockwise
    }

    // Translate the canvas origin to the center
    translate(centerX, centerY);

    // Save the current settings
    push();

    // Rotate the canvas for the shape redraw
    rotate(radians(angle * rotateDir));

    // Draw background circle
    fill(120, 88, 111);
    stroke(120, 88, 111);
    ellipse(0, 0, height, height);

    // Draw center rectangle
    fill(230, 199, 156);
    stroke(230, 199, 156);
    rectMode(CENTER); // Center rect around (0,0)
    rect(0,0, rectSize, rectSize);
    rect(0, 0, rectSize * mouseX/15, rectSize * mouseX/15);

    // Draw center crossing rectangles
    if(colorScheme == 1){
        fill(123, 158, 168); // grey blue
        stroke(123, 158, 168);
    } else {
        fill(111, 208, 140); // green
        stroke(111, 208, 140);
    }
    
    rect(0, 0, 25, width * 1.5);
    rect(0,0, width * 1.5, 25);

    // Draw little circle
    fill(120, 88, 111);
    stroke(120, 88, 111);
    ellipse(0, 0, littleCircle * mouseX/15, littleCircle * mouseX/15);

    // Draw four spokes of ellipses and diamonds 
    // at 90 degree intervals
    drawEllipse();
    drawRects();
    
    rotate(radians(90));
    drawEllipse();
    drawRects();

    rotate(radians(90));
    drawEllipse();
    drawRects();

    rotate(radians(90));
    drawEllipse();
    drawRects();

    // Return to saved settings
    pop();

    angle = angle + mouseY/100;
}

function drawEllipse(){
    // Set color of ellipses
    if(colorScheme == 1){
        fill(111, 208, 140); // green
        stroke(111, 208, 140);
    } else {
        fill(123, 158, 168); // grey blue
        stroke(123, 158, 168);
    }
    

    var circleSize = circleStart;
    var circleInc = 5;

    circleSize = circleSize * (width - mouseX)/150;
  
    // Draw a line of ellipses
    ellipse(shapeSpace, shapeSpace, circleSize, circleSize);
    // Draw first row dots
    var dotSize = 4;
    push(); // Save settings
    fill(205, 223, 160); // yellow
    stroke(0);
    rect(shapeSpace, shapeSpace, circleSize/dotSize, circleSize/dotSize);
    pop(); // restore settings
    
    circleSize += circleInc;
    ellipse(2 * shapeSpace, 2 * shapeSpace, circleSize, circleSize);
    // Draw second row dots
    push(); // Save settings
    fill(120, 88, 111); // purple
    rect(2 * shapeSpace, 2 * shapeSpace, circleSize/dotSize, circleSize/dotSize);
    pop(); // restore settings

    circleSize += circleInc;
    ellipse(3 * shapeSpace, 3 * shapeSpace, circleSize, circleSize);
    // Draw third row of dots
    push(); // Save settings
    fill(205, 223, 160); // yellow
    stroke(0);
    rect(3 * shapeSpace, 3 * shapeSpace, circleSize/dotSize, circleSize/dotSize);
    pop(); // Restore settings

    circleSize += circleInc;
    ellipse(4 * shapeSpace, 4 * shapeSpace, circleSize, circleSize);
    // Draw fourth row of dots
    push(); // Save settings
    fill(120, 88, 111); // purple
    rect(4 * shapeSpace, 4 * shapeSpace, circleSize/dotSize, circleSize/dotSize);
}

function drawRects(){
    // Draws a line of rectangles 

    // Set color of rectangles
    fill(205, 223, 160); // yellow
    stroke(120, 88, 111); // purple

    // Save current settings
    push();

    // Rotate canvase so rectangles craw as diamonds
    rotate(radians(45));

    rectMode(CENTER); // draw rects from center
    var sqSize = startSize * mouseX/100;
    var sqInc = 5;
    // Draw first rectangle
    rect(shapeSpace, shapeSpace, sqSize, sqSize);

    // Draw second rectangle
    sqSize += sqInc;
    rect(shapeSpace + 2 * sqSize, shapeSpace + 2 * sqSize, sqSize, sqSize);

    // Draw third rectangle
    sqSize += sqInc;
    rect(shapeSpace + 3 * sqSize, shapeSpace + 3 * sqSize, sqSize, sqSize);

    // Draw fourth rectangle
    sqSize += sqInc;
    rect(shapeSpace + 4 * sqSize, shapeSpace + 4 * sqSize, sqSize, sqSize);

    // Draw dots
    stroke(0);
    fill(111, 208, 140); // green
    var dotSize = 3;
    ellipse(shapeSpace + 4 * sqSize, shapeSpace + 4 * sqSize, sqSize/dotSize, 
        sqSize/dotSize);

    // third row dots
    fill(120, 88, 111); // purple
    sqSize -= sqInc; // Set sqSize to third square
    ellipse(shapeSpace + 3 * sqSize, shapeSpace + 3 * sqSize, sqSize/dotSize, 
        sqSize/dotSize);

    // second row dots
    fill(111, 208, 140); // green
    sqSize -= sqInc;
    ellipse(shapeSpace + 2 * sqSize, shapeSpace + 2 * sqSize, sqSize/dotSize, 
        sqSize/dotSize);

    // first row dot
    fill(120, 88, 111); // purple
    ellipse(shapeSpace, shapeSpace, sqSize/dotSize, 
        sqSize/dotSize);

    // Return to saved settings
    pop();
}

function mousePressed(){
    colorScheme = -colorScheme;
}

Project-03-Dynamic-Drawing

-The triangles rotate clockwise when mouse moving to the right, and counterclockwise when moving to the left

-The color become lighter when mouse moving to the bottom right, and darker when moving to the top left

-The triangle and change distance as mouse moving left, and it do the opposite when moving right.

– The smile faces shrink as mouse moves.

sketchDownload
/* Jiayi Chen
   jiayiche    Section A */
function setup() {
     createCanvas(600, 450);
     rectMode(CENTER);
}

function draw() {
    print('mouseX='+ mouseX +'mouseY'+mouseY)
    //change background
    backgroundchange();

    // smile face background
    for (var a=5;a<600;a=a+35){
        for (var b=0;b<450;b=b+35){
        push();
        translate(a,b);
        smileface();
        //change size
        var mx =constrain(mouseX,0,450)
        var my =constrain(mouseY,0,300)
            if(dist(mx,my,a,b)<= 150){ 
                d=30* dist(mx,my,a,b)/150;
            }
        pop();
        } 
    }
    //floating triangle and rectangle
    translate(constrain(mx,0,575),constrain(my,0,425));
    push();
    noStroke()
    cr=mx/450*255
    fill(cr,cr,cr,200)
    rect(0,0,50,50);
    var ang=mouseX/600*360
    //6 triangles
    push();
    scale(3*constrain(my,0,450)/450*3)
    push();
    triDist=100*constrain(mx,0,600)/600
    rotate(radians(ang));
    translate(triDist,0);
    triangle(0, 30, 30, 30, 15, 15);
    pop();
    push();
    rotate(radians(ang+60));
    translate(triDist,0);
    triangle(0, 30, 30, 30, 15, 15);
    pop();
    push();
    rotate(radians(ang+120));
    translate(triDist,0);
    triangle(0, 30, 30, 30, 15, 15);
    pop();
    push();
    rotate(radians(ang+180));
    translate(triDist,0);
    triangle(0, 30, 30, 30, 15, 15);
    pop();
    push();
    rotate(radians(ang+240));
    translate(triDist,0);
    triangle(0, 30, 30, 30, 15, 15);
    pop();
    push();
    rotate(radians(ang+300));
    translate(triDist,0);
    triangle(0, 30, 30, 30, 15, 15);
    pop();
    pop();
    pop();
}



var x=16
var y=16
var d=30



//single simle face
function smileface(){
    push();
    fill('yellow')
    //head
    ellipse(x,y,d); 
    //mouth
    arc(x, y+d*1/7, d/2, d/2, 0, PI); 
    //eye
    fill(0)
    ellipse(x+d*1/5,y-d*1/5,d/6);
    ellipse(x-d*1/5,y-d*1/5,d/6);
    pop();
}


   //change in background
function backgroundchange(){
    var r = mouseX/600*255
    var g = mouseX/600*255
    var b = mouseY/600*255
    background(r,g,b)
}

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

      //  }
   // }
}