Hello
I'm working in an array of squares that varies size according to it distance of the mouse.
It's part of a bigger stuff.
I got this weird circle of "bigger than should be" squares in an specific distance.
I don't know why this is happening.
Any help most welcome.
Thanks
I've made a clean version just with this part of the sketch, so it's easy to read.
The sketch is at:
www.kubrusly.com/vicente/erro/
and the code is also here:
Quote:int d1=200,d2=150,incr=4;
int marginL=0,marginT=0;
float tamQ=0;
color c1;
color c2;
Vivo v[][] = new Vivo[d1][d2];
void setup() {
size(800,600);
smooth();
imageMode(CENTER);
rectMode(CENTER);
background (255);
noStroke();
for(int i=0;i<d1; i++){
for(int a=0;a<d2; a++){
v[i][a]= new Vivo (incr*i,incr*a);
}
}
}
[color=#CC6600]void draw(){
c2=color(0);
c1=color(255);
fill(c1);
rect(width/2,height/2,width,height);
fill(c2);
for(int i=0;i<d1; i++){ // <- draw the array
for(int a=0;a<d2; a++){
v[i][a].born_quad();
}
}
}
class Vivo{
float var, centX,centY,x=-0.6;
Vivo(float in_centX,float in_centY){
centX=in_centX;
centY=in_centY;
}
void born_quad(){
this.var= dist(this.centX,this.centY,
mouseX ,mouseY)/100; // <- get distance from mouse
rect(this.centX+marginL,this.centY+marginT,tamQ-this.var*x,tamQ-this.var*x); // <- use it to set size
}
}