Skip to content

Instantly share code, notes, and snippets.

@kamiller
Created June 28, 2012 20:07
Show Gist options
  • Save kamiller/3013605 to your computer and use it in GitHub Desktop.
Save kamiller/3013605 to your computer and use it in GitHub Desktop.
python rounded rectangle using cairo and arc
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()
@safield
Copy link

safield commented Feb 19, 2020

How do you fill it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment