rounded corners with plane or

Nov 26, 2012 at 10:17pm

rounded corners with plane or


I got two questions:

I want to draw:
2 rectangles

rectangle 1: rectangle with rounded corners, edges stroked with blue and with transparent fill
rectangle 2: rectangle with rounded corners, edges stroked with blue and filled with a red color

which way is it the best way of doing this? with with the plane and setting size with scale or with



Nov 27, 2012 at 10:37am

I had this task with GL. After scouring a all the OpenGL forums I could find, it turns out the GL approach is to draw a lot of triangles.

I was using and JavaScript anyway, so that’s how I implemented the task. For better or worse I do not own the code, so I can’t simply post it.

The basic approach is to divide the rounded rectangle into (1) an inscribed rectangle (with square corners); (2) four rectangles along the edges of the inscribed rectangle; and (3) quarter-circles at the four corners. The last component is where the OpenGL idiom tri_fan is your friend. Otherwise it’s a bit of tedious math and a couple of for loops.

All of this did make me shed a brief tear for QuickDraw, which did all the heavy lifting for RoundRects.

Hope this is of some help.


You must be logged in to reply to this topic.