Carly Sacco – Project-03- Dynamic Drawing

sketch

//Carly Sacco
//Section C
//csacco@andrew.cmu.edu
//Project 3

var x = 300;
var y = 400;
var dx = 1 ;
var dy = -1;

function setup() {
    createCanvas(640, 480);	
}

function draw() {
	background(95, mouseX * .7, 227);
	//fish head
	fill(50, 162, 168);
	noStroke();
	push();
	translate(width / 2, height / 2);
    rotate(PI / 4);
    rect(-50, -50, 300, 300, 30);
	pop();
	
	fill(184, 213, 214);
	noStroke();
	push();
	translate(width / 2, height / 2);
    rotate(PI / 4);
    rect(-25, -25, 250, 250, 30);
	pop();
	
	//fish eyes
	fill('white');
	ellipse(290, 315, 50, 65);
	ellipse(350, 315, 50, 65);
	
	fill('black');
	//letting the black of the eye move based on the mouse
	eyeY = constrain(mouseY, 310, 330);
	ellipse(290, eyeY, 35, 35);
	ellipse(350, eyeY, 35, 35);
	
	//fish  mouth
	fill(227, 64, 151);
	noStroke();
	push();
	translate(320, 410);
	rectMode(CENTER)
    rotate(mouseX / 150); //the mouth spins based on mouseX
    rect(0, 0, 100, 100, 30);
	pop();
	
	fill(120, 40, 82);
	noStroke();
	push();
	translate(width / 2, height / 2);
    rotate(PI / 4);
    rect(95, 95, 50, 50, 30);
	pop();	
	
	//fins
	fill(209, 197, 67);
	quad(460, 350, 510, 300, 510, 450, 460, 400);
	quad(200, 350, 150, 300, 150, 450, 200, 400);
	
	//bubbles
	var bub = random(25, 60);
	fill(237, 240, 255);
	ellipse(x, y, 50, 50);
	ellipse(x, y, bub, bub);
	ellipse(200, y, bub, bub);
	ellipse(mouseX * .5, mouseY * .5, bub, bub);
	ellipse(mouseX * .25, mouseY * .25, bub, bub);
	ellipse(mouseX * .75, mouseY * .75, bub, bub);
	ellipse(mouseX * .5, mouseY * .25, bub, bub);
	ellipse(500, y, bub, bub);
	ellipse(250, 500, bub, bub);
	x += dx;
	y += dy;

	//so that they bounce off the edges
	if (x > 640) {
		dx = -dx;
	}
	if (y < 0) {
		dy = -dy;
	}
	if (y > 480) {
		dy = -dy;
	}
	if (x < 0) {
		dx = -dx;
		dy = random(1,5);
	}	
}


I thought making a fish with aspects that moved based on the cursor would be a fun way of how humans normally try to get fish’s attention. I learned a lot about how certain things can be controlled and how with others it’s fun to let them just run.

Leave a Reply