[whatwg] Canvas roundedRect

Igor Trindade Oliveira itrindade.oliveira at gmail.com
Thu Jun 21 09:59:07 PDT 2012


Currently, canvas2d does not have support for rounded rectangles and
the web developers are implementing rounded rectangles using arcs or
bezier curves.[1][2]
So i propose the addition of two new functions:

void fillRoundedRect(unrestricted double x, unrestricted double y,
unrestricted double w, unrestricted double h, unrestricted double
xRadius, unrestricted double yRadius);
void strokeRoundedRect(unrestricted double x, unrestricted double y,
unrestricted double w, unrestricted double h, unrestricted double
xRadius, unrestricted double yRadius);

Where the xRadius and yRadius arguments specify the radii of the
ellipses defining the corners of the rounded rectangle.

Additionally, if we know that the path is a rounded rectangle, we can
make optimizations in the graphics libraries reducing the amount of
tesselations.

[1] http://www.scriptol.com/html5/canvas/rounded-rectangle.php
[2] http://www.supercalifrigginawesome.com/Extending-Canvas-to-Draw-Rounded-Rectangles


More information about the whatwg mailing list