Reputation: 59
I am experimenting some graphics functions which I learned at the class. In the book, it says that integer calculation improves performance in C++. But I am doing it on JavaScript. Does it matter in Javascript?
On Chrome, it runs smoothly. Not surprisingly, its performance decreases significantly in Firefox 19 and IE10
function circ(cx, cy, rad, color){ //Using second-order differential
var x = 0;
var y = rad;
var d = 1 - rad;
var deltaE = 3;
var deltaSE = -2*rad+5;
ctx.beginPath();
ctx.strokeStyle = color;
ptc(cx,cy,x,y);
while(y>x){
if(d<0){ //Select E
d+=deltaE;
deltaE +=2;
deltaSE +=2;
}
else{ //Select SE
d+=deltaSE;
deltaE+=2;
deltaSE+=4;
y--;
}
x++;
ptc(cx,cy,x,y);
}
ctx.stroke();
}
Upvotes: 0
Views: 68
Reputation:
If you are dealing with very large fractions then sure, the simpler the numbers the faster it'll run, but the less smooth any animation based on that number will be.
Upvotes: 1