[cairo-commit] pycairo/examples/cairo_snippets/snippets ellipse.py, 1.1, 1.2

Steve Chaplin commit at pdx.freedesktop.org
Wed Jul 16 20:41:58 PDT 2008


Committed by: stevech1097

Update of /cvs/cairo/pycairo/examples/cairo_snippets/snippets
In directory kemper:/tmp/cvs-serv11561/examples/cairo_snippets/snippets

Modified Files:
	ellipse.py 
Log Message:
'SC'

Index: ellipse.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets/ellipse.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ellipse.py	29 Apr 2006 02:29:24 -0000	1.1
+++ ellipse.py	17 Jul 2008 03:41:56 -0000	1.2
@@ -1,6 +1,6 @@
-snippet_normalize (cr, width, height)
+snippet_normalize(cr, width, height)
 
-def path_ellipse (cr, x, y, width, height, angle=0):
+def path_ellipse(cr, x, y, width, height, angle=0):
     """
     x      - center x
     y      - center y
@@ -9,29 +9,25 @@
     angle  - angle in radians to rotate, clockwise
     """
     cr.save()
-    cr.translate (x, y)
-    cr.rotate (angle)
-    cr.scale (width / 2.0, height / 2.0)
-    cr.arc (0.0, 0.0, 1.0, 0.0, 2.0 * M_PI)
+    cr.translate(x, y)
+    cr.rotate(angle)
+    cr.scale(width / 2.0, height / 2.0)
+    cr.arc(0.0, 0.0, 1.0, 0.0, 2.0 * M_PI)
     cr.restore()
 
-def fill_and_stroke (cr, fill_c, stroke_c, stroke_linewidth):
-    assert fill_c is not None or stroke_c is not None
-    cr.save()
-
-    if fill_c is not None:
-        cr.set_source_rgba(*fill_c)
-        if stroke_c is not None:
-            cr.fill_preserve()
-        else:
-            cr.fill()
 
-    if stroke_c is not None:
-        cr.set_source_rgba(*stroke_c)
-        cr.set_line_width(stroke_linewidth)
-        cr.stroke()
+path_ellipse(cr, 0.5, 0.5, 1.0, 0.3, M_PI/4.0)
 
-    cr.restore()
+# fill
+cr.set_source_rgba(1,0,0,1)
+cr.fill_preserve()
 
-path_ellipse (cr, 0.5, 0.5, 1.0, 0.3, M_PI/4.0)
-fill_and_stroke (cr, (1,0,0,1), (0,0,0,1), 0.02)
+# stroke
+# reset identity matrix so line_width is a constant
+# width in device-space, not user-space
+cr.save()
+cr.identity_matrix()
+cr.set_source_rgba(0,0,0,1)
+cr.set_line_width(3)
+cr.stroke()
+cr.restore()



More information about the cairo-commit mailing list