[whatwg] Canvas - Exception on arc with negative radius

Dirk Schulze vbs85 at gmx.de
Fri Mar 27 12:50:47 PDT 2009


Hi,

why does the spec want an INDEX_SIZE_ERR exception on arc's with a
negative radius? This blocks further drawings. 

Here is a short example:

<!DOCTYPE html>
<html>
<script>
    function drawShape()
    {
        var canvas = document.getElementById("canvas");
        var ctx = canvas.getContext("2d");

        //arc(x, y, radius, startAngle, endAngle, anticlockwise)
        ctx.beginPath();
        ctx.arc(30, 30,-20, 0, 2*Math.PI, false);
        ctx.fill();

        ctx.beginPath();
        ctx.fillRect(10,10,30,30);
    }
</script>
<body onload="drawShape();">
<canvas id="canvas" width="100" height="60">
</body>
</html>

The circle, drawn by the arc, has a negative radius. A negative radius
doesn't make sense for circles, but an INDEX_SIZE_ERR exception stops
further drawing of the rect, even if the code is ok there.

Another example is: http://blahbleh.com/molecools.php?name=1,2%
20dimethylcyclopropane

If you turn the molecule a bit, the circles disappear with a
INDEX_SIZE_ERR exception.

Isn't it better to just ignore the arc and go on with the drawing, like
Firefox does? And perhaps the same for arcTo?

-Dirk




More information about the whatwg mailing list