[cairo-commit] pycairo/examples spiral.py,1.3,1.4

Steve Chaplin commit at pdx.freedesktop.org
Sun May 1 19:25:53 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/examples
In directory gabe:/tmp/cvs-serv5655/examples

Modified Files:
	spiral.py 
Log Message:
SC

Index: spiral.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/spiral.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- spiral.py	15 Apr 2005 03:25:37 -0000	1.3
+++ spiral.py	2 May 2005 02:25:51 -0000	1.4
@@ -1,13 +1,10 @@
 #!/usr/bin/env python
 """cairo/cairo-demo/png/spiral.c translated into Python
-Modified to produce PostScript output
 """
 
 import cairo
 
-PPI = 300
-WIDTH_IN, HEIGHT_IN = 4, 4
-WIDTH, HEIGHT = WIDTH_IN * 96.0, HEIGHT_IN * 96.0
+WIDTH, HEIGHT = 600, 600
 
 def draw_spiral (ctx, width, height):
     wd = .02 * width
@@ -27,13 +24,8 @@
     ctx.stroke()
 
 
-try:
-    fileObject = file('spiral.ps', 'wb')
-except IOError, exc:
-    raise SystemExit("%s: %s" % (exc.filename, exc.strerror))
-
 ctx = cairo.Context()
-surface = cairo.ps_surface_create (fileObject, WIDTH_IN, HEIGHT_IN, PPI, PPI)
+surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
 ctx.set_target_surface(surface)
 
 ctx.rectangle (0, 0, WIDTH, HEIGHT)
@@ -42,4 +34,4 @@
 
 draw_spiral (ctx, WIDTH, HEIGHT)
 
-ctx.show_page()  # Apr 15 2005 - gives Segmentation fault
+surface.write_to_png('spiral.png')




More information about the cairo-commit mailing list