In this small app I use the MouseX, MouseY to allow the inner circles to follow the mouse location. The formula used to determine the the location of the mouse is: location = (MouseX-SizeOfWindowX)/10. The same formula can be used to calculate the Y coordinates to draw.
//Write a processing program to simulate the following picture.
//The size of the picture is 800x600 and it can be divided into 12(=4x3)
//cells with size of 200x200. Each cell includes 3 ellipses with different colors and size.
//Anton Carlson
//97470043
void setup() {
size(800,600);
background(34,139,34);
smooth();
noStroke();
}
void draw() {
background(34,139,34);
for(int x=0;x<800;x=x+200)
{
for(int y=0;y<600;y=y+200)
{
fill(122,255,255);
ellipse(x+100,y+100,200,200);
fill(255,255,255);
ellipse(x+100+(mouseX-400)/9,y+100+(mouseY-300)/9,100,100);
fill(0,0,0);
ellipse(x+100+(mouseX-400)/9,y+100+(mouseY-300)/9,50,50);
}
}
}
沒有留言:
張貼留言