altering surrounding circles' sizes of a moused over circle. - circle packing algorithm.
in
Programming Questions
•
3 years ago
Hi,
I am new to processing. I have applied a circle packing algorithm on my processing project. and I have managed to do a mouseover effect on any circle - the circle size and colour will change.
I am now trying to also alter the circle size and colour of surrounding circles that touches the corners of that particular circle that I have moused-over, unfortunately, I can only change the color of surrounding circles but not the size of the circles.
this is the step that I took.
1) hover on any circle
2) check for surrounding circles touches the hover circle
3) if touches increase the surrounding circle sizes and change color
4) redraw
I can retrieve the size of all the surrounding circles, but I am unable to change the size of the circles.
I would be most grateful if you could share with me how i can change the size of the surrounding circles prior to sending for redraw?
Attached is my code.
FM
for(int i = circles.size()-1 ; i >= 0 ; i--){
Circle c = getCircle(i);
if(c.contains(mouseX,mouseY))
{
mouseHover(i);
for(int j = circles.size()-1; j >= 0 ; j--){
if(j != i){
mc = getCircle(j);
float rrr = (Integer)radius.get(i);
c.radius += 0.02;
if(rrr > 20 && rrr < 40){
if((int)c.radius >= rrr*1.7){
c.radius = rrr*1.6;
}
else if((int)c.radius >= 90){
c.radius = 90;
}
}else if(rrr >= 40 && rrr < 70){
if((int)c.radius >= rrr*1.5){
c.radius = rrr*1.5;
}
}else if(rrr >= 70){
if((int)c.radius >= rrr*1.1){
c.radius = rrr*1.1;
}
} else if (rrr <= 20){
c.radius += 0.02;
if((int)c.radius >= rrr*2.2){
c.radius = rrr*2.2;
}
}
if(dist(c.x,c.y,mc.x,mc.y) <= c.radius + mc.radius){
mc.radius += 0.02;
if(mc.radius >= c.radius * 1.5){
mc.radius = c.radius * 1.5;
}
}
1
