jennyzha-project-03

sketch

var angle = 0;
var m = 0;
var n = 0;
var size = 0;
var sizen = 0;
var x = 0;
var z = 0;

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

function draw() {
	x = max(min(mouseX, 255), 0);
	z =max(min(mouseX, 255), 0);
	background(0);
	fill(x, 255, z);
	ellipseMode(CENTER);

//create ellipse with color dependent on where the mouse is

	m = max(min(mouseX, 640), 0);
	n = max(min(mouseY, 480), 0);
// //setting the x and y coordinates to be the max value between the mouse coordinates and the canvas size 

	size = m * 350 / 400;
	sizen = n * 350 / 400;
	//settin the size of the ellipse to be a function of the position of the coordinates


	push();
	ellipse(mouseX, mouseY, size, sizen);
	//using the variables to create an ellipse
	fill(x, 255, z);
	//filling the color for the ellipse based on where the mouse is on the canvas
	translate(mouseX,mouseY);
	//moving the ellipse based on where the ellipse is in the canvas
	rotate(radians(angle));
	//rotating the ellips
	pop();
	angle = angle +5;
}	

Leave a Reply