[cairo-commit] pycairo/examples context-subclass.py, 1.3, 1.4 gradient.py, 1.4, 1.5 hering.py, 1.4, 1.5 spiral.py, 1.2, 1.3 warpedtext.py, 1.7, 1.8

Steve Chaplin commit at pdx.freedesktop.org
Thu Apr 14 20:25:39 PDT 2005


Committed by: stevech1097

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

Modified Files:
	context-subclass.py gradient.py hering.py spiral.py 
	warpedtext.py 
Log Message:
SC 2005/04/15

Index: context-subclass.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/context-subclass.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- context-subclass.py	14 Apr 2005 12:05:26 -0000	1.3
+++ context-subclass.py	15 Apr 2005 03:25:37 -0000	1.4
@@ -25,16 +25,16 @@
 
     def draw(self):
         self.rectangle (0, 0, WIDTH, HEIGHT)
-        self.set_rgb_color (1, 1, 1)
+        self.set_source_rgb (1, 1, 1)
         self.fill()
 
         self.triangle (WIDTH/2, 20, 50)
-        self.set_rgb_color (1, 0, 0)
+        self.set_source_rgb (1, 0, 0)
         self.set_line_width(6)
         self.fill()
 
         self.bowtie (WIDTH/2, 150, 50)
-        self.set_rgb_color (0, 1, 0)
+        self.set_source_rgb (0, 1, 0)
         self.stroke()
         
 surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)

Index: gradient.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/gradient.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- gradient.py	14 Apr 2005 12:05:26 -0000	1.4
+++ gradient.py	15 Apr 2005 03:25:37 -0000	1.5
@@ -14,19 +14,19 @@
 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.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.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 ()
 

Index: hering.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/hering.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- hering.py	14 Apr 2005 12:05:26 -0000	1.4
+++ hering.py	15 Apr 2005 03:25:37 -0000	1.5
@@ -13,7 +13,7 @@
     MAX_THETA = .80 * pi * 2
     THETA_INC = 2.0 * MAX_THETA / (LINES-1)
 
-    ctx.set_rgb_color (0, 0, 0)
+    ctx.set_source_rgb (0, 0, 0)
     ctx.set_line_width (2.0)
 
     ctx.save()
@@ -31,7 +31,7 @@
     ctx.restore()
 
     ctx.set_line_width (6)
-    ctx.set_rgb_color (1, 0, 0)
+    ctx.set_source_rgb (1, 0, 0)
 
     ctx.move_to (width / 4.0, 0)
     ctx.rel_line_to (0, height)
@@ -47,7 +47,7 @@
 ctx.set_target_surface(surface)
 
 ctx.rectangle (0, 0, WIDTH, HEIGHT)
-ctx.set_rgb_color (1, 1, 1)
+ctx.set_source_rgb (1, 1, 1)
 ctx.fill()
 
 draw_hering (ctx, WIDTH, HEIGHT)

Index: spiral.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/spiral.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- spiral.py	11 Nov 2004 15:32:12 -0000	1.2
+++ spiral.py	15 Apr 2005 03:25:37 -0000	1.3
@@ -23,7 +23,7 @@
 	ctx.rel_line_to (0, - (height - hd * (2*i)))
 	ctx.rel_line_to (width - wd * (2 * i + 1), 0)
 
-    ctx.set_rgb_color (0, 0, 1)
+    ctx.set_source_rgb (0, 0, 1)
     ctx.stroke()
 
 
@@ -33,12 +33,13 @@
     raise SystemExit("%s: %s" % (exc.filename, exc.strerror))
 
 ctx = cairo.Context()
-ctx.set_target_ps (fileObject, WIDTH_IN, HEIGHT_IN, PPI, PPI)
+surface = cairo.ps_surface_create (fileObject, WIDTH_IN, HEIGHT_IN, PPI, PPI)
+ctx.set_target_surface(surface)
 
 ctx.rectangle (0, 0, WIDTH, HEIGHT)
-ctx.set_rgb_color (1, 1, 1)
+ctx.set_source_rgb (1, 1, 1)
 ctx.fill()
 
 draw_spiral (ctx, WIDTH, HEIGHT)
 
-ctx.show_page()
+ctx.show_page()  # Apr 15 2005 - gives Segmentation fault

Index: warpedtext.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/warpedtext.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- warpedtext.py	14 Apr 2005 12:05:26 -0000	1.7
+++ warpedtext.py	15 Apr 2005 03:25:37 -0000	1.8
@@ -41,20 +41,20 @@
 
 ctx.identity_matrix()
 
-solidpattern = ctx.pattern
+solidpattern = ctx.source
 
 # background
 pat = cairo.Pattern.create_linear(0.0, 0.0, 0, HEIGHT)
-pat.add_color_stop (1, 0, 0, 0, 1)
-pat.add_color_stop (0, 1, 1, 1, 1)
+pat.add_color_stop_rgba (1, 0, 0, 0, 1)
+pat.add_color_stop_rgba (0, 1, 1, 1, 1)
 
 ctx.rectangle (0,0,WIDTH,HEIGHT)
-ctx.set_pattern (pat)
+ctx.set_source (pat)
 ctx.fill ()
 
 # foreground
-ctx.set_pattern (solidpattern)
-ctx.set_rgb_color(1,1,1)
+ctx.set_source (solidpattern)
+ctx.set_source_rgb (1,1,1)
 
 # spiral text
 ctx.select_font_face("Sans")
@@ -75,7 +75,7 @@
 
 # curly text
 ctx.move_to(0, 0)
-ctx.set_rgb_color(0.3, 0.3, 0.3)
+ctx.set_source_rgb(0.3, 0.3, 0.3)
 text = "I am curly :)"
 ctx.text_path(text)
 textwidth, textheight = ctx.text_extents(text)[2:4]




More information about the cairo-commit mailing list