and when the mouse enter the blockchain area , the area repulse a little.
My problem is that I used setinterval for repulsing that draw svg frequently on new changed position circles therefore we see lag in the browser.
Any idea to make it smoother?
setInterval(function () {
$('.btn,.a,.a1').each(function(index, el){
el = $(el);
position = el.position();
x0 = position.left;
y0 = position.top;
x1 = mouse.x;
y1 = mouse.y;
distancex = x1-x0;
distancey = y1-y0;
distance = Math.sqrt((distancex * distancex) + (distancey * distancey));
powerx = x0 - (distancex / distance) * magnet / distance;
powery = y0 - (distancey / distance) * magnet / distance;
forcex = (forcex + (el.data('homex') - x0) / 2) / 2.1;
forcey = (forcey + (el.data('homey') - y0) / 2) / 2.1;
el.css('left', powerx + forcex);
el.css('top', powery + forcey);
$('svg').remove();
var elem = document.getElementById('pp');
var params = { width: 350, height: 300 };
var two = new Two(params).appendTo(elem);
var vertices = [];
for(var i=1;i<=10;i++){
var r=getcenter("#azcir"+i);
vertices.push(new Two.Anchor(r[0], r[1]));
}
var r=getcenter("#azcir1");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir25");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir14");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir24");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir28");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir17");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir6");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir16");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir15");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir18");
vertices.push(new Two.Anchor(r[0],r[1]));
var r=getcenter("#azcir22");
vertices.push(new Two.Anchor(r[0],r[1]));
.
.
.
var poly = two.makePath(vertices, false, false);
poly.stroke = 'white';
poly.noFill();
two.update();
});
}, 1000/60);
Dots in code is near 30 other paths that i omitted for this ticket.