[cairo-commit] pycairo/examples/gtk cairo-knockout.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/gtk
In directory gabe:/tmp/cvs-serv5655/examples/gtk

Modified Files:
	cairo-knockout.py 
Log Message:
SC

Index: cairo-knockout.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/gtk/cairo-knockout.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo-knockout.py	4 Apr 2005 13:51:19 -0000	1.3
+++ cairo-knockout.py	2 May 2005 02:25:51 -0000	1.4
@@ -36,12 +36,12 @@
     ctx.set_target_surface(check)
     ctx.set_operator(cairo.OPERATOR_SRC)
 
-    ctx.set_rgb_color(0.4, 0.4, 0.4)
+    ctx.set_source_rgb(0.4, 0.4, 0.4)
     
     ctx.rectangle(0, 0, 2*CHECK_SIZE, 2*CHECK_SIZE)
     ctx.fill()
 
-    ctx.set_rgb_color(0.7, 0.7, 0.7)
+    ctx.set_source_rgb(0.7, 0.7, 0.7)
     
     ctx.rectangle(x, y, CHECK_SIZE, CHECK_SIZE)
     ctx.fill()
@@ -51,31 +51,31 @@
     ctx.restore()
 
     check_pattern = cairo.Pattern.create_for_surface (check)
-    ctx.set_pattern(check_pattern)
+    ctx.set_source(check_pattern)
     ctx.rectangle(0, 0, width, height)
     ctx.fill()
 
     ctx.restore()
     
 
-def draw_3circles(ctx, xc, yc, radius):
+def draw_3circles(ctx, xc, yc, radius, alpha):
     subradius = radius * (2 / 3. - 0.1)
 
-    ctx.set_rgb_color(1, 0, 0)
+    ctx.set_source_rgba(1, 0, 0, alpha)
     oval_path(ctx,
               xc + radius / 3. * math.cos(math.pi * 0.5),
               yc - radius / 3. * math.sin(math.pi * 0.5),
               subradius, subradius)
     ctx.fill()
 
-    ctx.set_rgb_color(0, 1, 0)
+    ctx.set_source_rgba(0, 1, 0, alpha)
     oval_path(ctx,
               xc + radius / 3. * math.cos(math.pi * (0.5 + 2/.3)),
               yc - radius / 3. * math.sin(math.pi * (0.5 + 2/.3)),
               subradius, subradius)
     ctx.fill()
 
-    ctx.set_rgb_color(0, 0, 1)
+    ctx.set_source_rgba(0, 0, 1, alpha)
     oval_path(ctx,
               xc + radius / 3. * math.cos(math.pi * (0.5 + 4/.3)),
               yc - radius / 3. * math.sin(math.pi * (0.5 + 4/.3)),
@@ -105,7 +105,7 @@
     ctx.set_target_surface(overlay)
 
     # Draw a black circle on the overlay
-    ctx.set_rgb_color(0, 0, 0)
+    ctx.set_source_rgb(0, 0, 0)
     oval_path(ctx, xc, yc, radius, radius)
     ctx.fill()
 
@@ -114,7 +114,7 @@
 
     # Draw 3 circles to the punch surface, then cut
     # that out of the main circle in the overlay
-    draw_3circles(ctx, xc, yc, radius)
+    draw_3circles(ctx, xc, yc, radius, 1.0)
     
     ctx.restore()
 
@@ -124,9 +124,8 @@
     ctx.save()
 
     ctx.set_target_surface(circles)
-    ctx.set_alpha(0.5)
     ctx.set_operator(cairo.OPERATOR_OVER)
-    draw_3circles(ctx, xc, yc, radius)
+    draw_3circles(ctx, xc, yc, radius, 0.5)
     
     ctx.restore()
 




More information about the cairo-commit mailing list