# HG changeset patch # User Jordan Miner # Date 1247970527 18000 # Node ID dcaa95190f4be9456948ab3c473fde2fe7e383d3 # Parent 96b29f2efa4d7577668e73c2d782265e1185432e Add roundedRectangle() method to Graphics. diff -r 96b29f2efa4d -r dcaa95190f4b dynamin/painting/graphics.d --- a/dynamin/painting/graphics.d Sat Jul 18 02:41:26 2009 -0500 +++ b/dynamin/painting/graphics.d Sat Jul 18 21:28:47 2009 -0500 @@ -356,6 +356,23 @@ void rectangle(real x, real y, real width, real height) { cairo_rectangle(cr, x, y, width, height); } + /** + * Adds a rectangle with rounded corners as a sub-path--a line will + * not connect it to the current point. + */ + void roundedRectangle(Rect rect, real radius) { + roundedRectangle(rect.x, rect.y, rect.width, rect.height, radius); + } + /// ditto + void roundedRectangle(real x, real y, real width, real height, real radius) { + alias radius r; + cairo_new_sub_path(cr); + arc(x+r, y+r, r, Pi, 3*Pi/2); + arc(x+width-r, y+r, r, 3*Pi/2, 0); + arc(x+width-r, y+height-r, r, 0, Pi/2); + arc(x+r, y+height-r, r, Pi/2, Pi); + closePath(); + } /// void closePath() { cairo_close_path(cr);