Mercurial > projects > dynamin
changeset 16:dcaa95190f4b
Add roundedRectangle() method to Graphics.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 18 Jul 2009 21:28:47 -0500 |
parents | 96b29f2efa4d |
children | ef81af74a306 |
files | dynamin/painting/graphics.d |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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);