|
BImage a;
float x;
float y;
int x_direction;
int y_direction;
float x_speed;
float y_speed;
int s;
int t;
float i=0;
float inc = TWO_PI/25.0;
color c;
//setup-------------------------------------------------------------
void setup(){
size(300,300);
x=width/2;
y=height/2;
x_direction=1;
y_direction=1;
x_speed=1.2;
y_speed=1.5;
s=20;
t=20;
//a=loadImage("1.jpg");
}
//loop------------------------------------------------------------------
void loop(){
fill(0);
rect(0,0,300,300);
//background(0,0,0);
noStroke();
ellipseMode(CENTER_DIAMETER);
fill(220-mouseX*mouseY/10,160,255);
ellipse(150,60,20,20);
fill(170,255-mouseX*mouseY/10,200);
ellipse(50,225,20,20);
fill(160,200,255-mouseX*mouseY/10);
ellipse(250,225,20,20);
smooth();
// stroke(255,255,255);
//line(x,y,width/2,height/2);
fill(255,255,255);
// triangle(150,60, 50,225, 250,225);
//movingpoint-------------------------------------------
// c = getPixel(x, y);
noStroke();
//fill(c);
fill(255-y,255-x,255);
ellipse(x,y,s,t);
//image(a,x,y);
//if(x>300-s||x<0||y>300-t||y<0){
//background(255,255,255);
//}
if(x>300-s||x<0||x*y<300||x==150&&y==60){
x_direction=x_direction*-1;
}
if(y>300-t||y<0||x*y<300){
y_direction=y_direction*-1;
}
x=x+x_direction*x_speed;
y=y+y_direction*y_speed;
}
void keyPressed(){
if(key==RIGHT){
x=x+6;
}
if(key==LEFT){
x=x-6;
}
if(key==UP){
y=y-6;
}
if(key==DOWN){
y=y+6;
}
if(key==1){
ellipse(x,y,s,t);
}
}
void mousePressed()
{
fill(255,255,255);
ellipse(x,y,5,5);
}
|