一応マウス位置のはデカくなるというインタラクション付きです。
ソースコードは以下。
int l=50;
int num;
Qube[] qube;
void setup(){
size(800,500,OPENGL);
//smooth();
frameRate(30);
colorMode(HSB,100);
float x=l;
float y=l;
for(; x<width; x+=l){
for(; y<height; y+=l) ;
}
num = int(x*y);
qube = new Qube[num];
for(int i=0; i<num; i++){
qube[i] = new Qube(l,l,l);
}
}
void draw(){
background(99);
lights();
directionalLight(99,0,99,0,0,-1);
int count=0;
for(float x=l; x<width; x+=l){
for(float y=l; y<height; y+=l){
pushMatrix();
translate(x,y);
rotateX(frameCount*PI/60 + x);
rotateY(frameCount*PI/60 + y);
float h = map(x,0,width,0,100);
float s = map(y,0,height,0,100);
float b = 99;
fill(h,s,99,60);
noStroke();
qube[count].getDistance(x,y);
qube[count].changeSize();
qube[count].display();
count++;
popMatrix();
}
}
}
class Qube{
int XL;
int YL;
int ZL;
float xl;
float yl;
float zl;
float range = 200;
float distance=0;
boolean isOver = false;
Qube(){ }
Qube(int XL, int YL, int ZL){
this.XL = XL;
this.YL = YL;
this.ZL = ZL;
}
void display(){
box(xl,yl,zl);
}
void getDistance(float x,float y){
distance=sqrt(sq(mouseX-x)+sq(mouseY-y));
if(distance<range) isOver=true;
else isOver=false;
}
void changeSize(){
if(isOver){
float s=1;
xl=XL+(range-distance)*s;
yl=YL+(range-distance)*s;
zl=ZL+(range-distance)*s;
}else{
xl=XL;
yl=YL;
zl=ZL;
}
}
}

0 件のコメント:
コメントを投稿