http://cairographics.org/cookbook/roundedrectangles/
http://graphics.stanford.edu/courses/cs248-98-fall/Final/q1....
and two more here (but I forgot to put the links where I got the code from, and I don't recall being my original code):
https://github.com/malkia/ufo/blob/master/samples/cairo/ui.l...
gfx:round_rect_a() gfx:round_rect_b() gfx:round_rect_c() gfx:round_rect_d()