[cairo-commit] pycairo/test cairo_image_surface_create_for_data.py, 1.3, 1.4

Steve Chaplin commit at pdx.freedesktop.org
Thu Sep 22 05:43:43 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/test
In directory gabe:/tmp/cvs-serv24805/test

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

Index: cairo_image_surface_create_for_data.py
===================================================================
RCS file: /cvs/cairo/pycairo/test/cairo_image_surface_create_for_data.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo_image_surface_create_for_data.py	16 Apr 2005 05:08:44 -0000	1.3
+++ cairo_image_surface_create_for_data.py	22 Sep 2005 12:43:41 -0000	1.4
@@ -9,33 +9,28 @@
 
 data = array.array('c', 'a' * WIDTH * HEIGHT * 4)
 stride = WIDTH * 4
-surface = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32,
-                                             WIDTH, HEIGHT, stride);
-ctx = cairo.Context()
-ctx.set_target_surface(surface)
+surface = cairo.ImageSurface.create_for_data (data, cairo.FORMAT_ARGB32,
+                                              WIDTH, HEIGHT, stride);
+del data  # to test that create_for_data() references 'data'
+ctx = cairo.Context (surface)
 
 ctx.scale (WIDTH/1.0, HEIGHT/1.0)
 
-pat = cairo.Pattern.create_linear(0.0, 0.0, 0.0, 1.0)
-pat.add_color_stop (1, 0, 0, 0, 1)
-pat.add_color_stop (0, 1, 1, 1, 1)
+pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0)
+pat.add_color_stop_rgba (1, 0, 0, 0, 1)
+pat.add_color_stop_rgba (0, 1, 1, 1, 1)
 
 ctx.rectangle (0,0,1,1)
-ctx.set_pattern (pat)
+ctx.set_source (pat)
 ctx.fill ()
 
-pat = cairo.Pattern.create_radial (0.45, 0.4, 0.1,
-                                   0.4,  0.4, 0.5)
-pat.add_color_stop (0, 1, 1, 1, 1)
-pat.add_color_stop (1, 0, 0, 0, 1)
+pat = cairo.RadialGradient (0.45, 0.4, 0.1,
+                            0.4,  0.4, 0.5)
+pat.add_color_stop_rgba (0, 1, 1, 1, 1)
+pat.add_color_stop_rgba (1, 0, 0, 0, 1)
 
-ctx.set_pattern (pat)
+ctx.set_source (pat)
 ctx.arc (0.5, 0.5, 0.3, 0, 2 * math.pi)
 ctx.fill ()
 
-try:
-    fileObject = file('cairo_image_surface_create_for_data.png', 'wb')
-except IOError, exc:
-    raise SystemExit("%s: %s" % (exc.filename, exc.strerror))
-
-surface.write_png(fileObject)
+surface.write_to_png ('cairo_image_surface_create_for_data.png')



More information about the cairo-commit mailing list