[cairo-commit] [cairo-www] src/cookbook
Carl Worth
cworth at freedesktop.org
Sat Feb 12 15:37:05 PST 2011
src/cookbook/roundedrectangles.mdwn | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
New commits:
commit 9527d429851ad8e7c7c74ef76fb5be5bdd71f324
Author: heltonbiker <heltonbiker at web>
Date: Sat Feb 12 15:37:05 2011 -0800
diff --git a/src/cookbook/roundedrectangles.mdwn b/src/cookbook/roundedrectangles.mdwn
index 3140ef2..bf046f8 100644
--- a/src/cookbook/roundedrectangles.mdwn
+++ b/src/cookbook/roundedrectangles.mdwn
@@ -114,10 +114,10 @@ Created by Helton Moraes (heltonbiker at gmail dot com). Uses round arcs and tak
""" 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*2, radius, 0*(pi/2), 1*(pi/2)) # ;o)
- cr.arc(a + radius, d - radius*2, radius, 1*(pi/2), 2*(pi/2))
+ 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()
@@ -126,19 +126,20 @@ Created by Helton Moraes (heltonbiker at gmail dot com). Uses round arcs and tak
### EXAMPLE
import cairo, Image
- # dimensions of some whole figure:
- fig_size = (800,600)
+ w,h = 800, 600
+ offset = 100
+ fig_size = (w,h)
# an area with coordinates of
# (top, bottom, left, right) edges in absolute coordinates:
- inside_area = (100,700,100,600)
+ inside_area = (offset, w-offset, offset, h-offset)
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, *fig_size)
cr = cairo.Context(surface)
cr.set_line_width(3)
cr.set_source_rgb(1,1,1)
- draw_rounded(cr, inside_area, 100)
+ draw_rounded(cr, inside_area, 150)
im = Image.frombuffer("RGBA",
fig_size,
More information about the cairo-commit
mailing list