Created
June 28, 2012 20:07
-
-
Save kamiller/3013605 to your computer and use it in GitHub Desktop.
python rounded rectangle using cairo and arc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def draw_rounded(cr, area, radius): | |
""" draws rectangles with rounded (circular arc) corners """ | |
from math import pi | |
a,b,c,d=area | |
cr.arc(a + radius, c + radius, radius, 2*(pi/2), 3*(pi/2)) | |
cr.arc(b - radius, c + radius, radius, 3*(pi/2), 4*(pi/2)) | |
cr.arc(b - radius, d - radius, radius, 0*(pi/2), 1*(pi/2)) # ;o) | |
cr.arc(a + radius, d - radius, radius, 1*(pi/2), 2*(pi/2)) | |
cr.close_path() | |
cr.stroke() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you fill it?