Different results using the same maths in different browsers

The problem is not with the Javascript math; it’s with the canvas.

http://jsfiddle.net/LDWBX/

function bigCircle(angle) {
    var radius = 5000; //the bigger, the worse
    var x = canvas.width/2 + radius*Math.cos(angle);
    var y = canvas.height/2 + radius*Math.sin(angle);

    ctx.beginPath();
    ctx.arc(x, y, radius, 0, 2 * Math.PI);
    ctx.lineWidth = 2;
    ctx.stroke();
}

Notice that numbers appear exactly the same as in Firefox, but the red arc is obviously drawn incorrectly in Chrome.

screenshot

Interestingly, this works for all angles that are multiples of Math.PI / 4 but is off for values between those (hence the undulating behavior in the OP’s example).

I’ve logged Chromium bug #320335.

EDIT: It looks like it was first reported in May 2012, and was caused by a bug in the Skia library.

It has now been resolved as fixed.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)