[cairo-commit] pycairo/examples/gtk cairo-knockout.py,1.5,1.6
Steve Chaplin
commit at pdx.freedesktop.org
Mon May 9 02:12:33 PDT 2005
- Previous message: [cairo-commit] pycairo/examples warpedtext.py,1.10,1.11
- Next message: [cairo-commit] pycairo/cairo cairogtkmodule.c, 1.18,
1.19 cairomodule.c, 1.30, 1.31 cairosvgmodule.c, 1.3,
1.4 pycairo-context.c, 1.46, 1.47 pycairo-font.c, 1.13,
1.14 pycairo-matrix.c, 1.14, 1.15 pycairo-misc.h, 1.1,
1.2 pycairo-path.c, NONE, 1.1 pycairo-pattern.c, 1.17,
1.18 pycairo-private.h, 1.20, 1.21 pycairo-surface.c, 1.34,
1.35 pycairo.h, 1.27, 1.28 pycairosvg-context.c, 1.4,
1.5 pycairosvg-private.h, 1.2, 1.3 Makefile.am, 1.11, 1.12
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: stevech1097
Update of /cvs/cairo/pycairo/examples/gtk
In directory gabe:/tmp/cvs-serv16365/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.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cairo-knockout.py 9 May 2005 00:52:47 -0000 1.5
+++ cairo-knockout.py 9 May 2005 09:12:31 -0000 1.6
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-"""Based on cairo-demo/X11/cairo-knockout.c
+"""Based on gtk+/test/testcairo.c
"""
from __future__ import division
@@ -12,7 +12,7 @@
def oval_path(ctx, xc, yc, xr, yr):
- matrix = cairo.Matrix ()
+ ctx.save()
ctx.translate (xc, yc)
ctx.scale (1.0, yr / xr)
@@ -22,14 +22,15 @@
0, 2 * math.pi)
ctx.close_path ()
- ctx.set_matrix (matrix)
+ ctx.restore()
def fill_checks(ctx, x, y, width, height):
+ # update to match testcairo.c
ctx.save()
CHECK_SIZE = 32
- check = ctx.target_surface.create_similar(cairo.FORMAT_RGB24,
- 2*CHECK_SIZE, 2*CHECK_SIZE)
+ check = ctx.target.create_similar(cairo.FORMAT_RGB24,
+ 2*CHECK_SIZE, 2*CHECK_SIZE)
check.set_repeat(1)
ctx.save()
@@ -82,21 +83,15 @@
subradius, subradius)
ctx.fill()
-def expose(drawingarea, event):
- drawable = drawingarea.window
- width = drawingarea.allocation.width
- height = drawingarea.allocation.height
+def draw (ctx, width, height):
radius = 0.5 * min(width, height) - 10
xc = width / 2.
yc = height / 2.
-
- ctx = cairo.gtk.create_cairo_context(drawable)
- surface = ctx.target
-
- overlay = surface.create_similar(cairo.FORMAT_ARGB32, width,height)
- punch = surface.create_similar(cairo.FORMAT_A8, width,height)
- circles = surface.create_similar(cairo.FORMAT_ARGB32, width,height)
+
+ overlay = ctx.target.create_similar(cairo.FORMAT_ARGB32, width, height)
+ punch = ctx.target.create_similar(cairo.FORMAT_A8, width, height)
+ circles = ctx.target.create_similar(cairo.FORMAT_ARGB32, width, height)
fill_checks(ctx, 0, 0, width, height)
@@ -120,7 +115,6 @@
ctx.set_operator(cairo.OPERATOR_OUT_REVERSE)
ctx.set_source_surface (punch, 0, 0)
ctx.paint()
- #ctx.show_surface(punch, width, height)
ctx.save()
@@ -133,14 +127,21 @@
ctx.set_operator(cairo.OPERATOR_ADD)
ctx.set_source_surface (circles, 0, 0)
ctx.paint()
- #ctx.show_surface(circles, width, height)
ctx.restore()
ctx.set_source_surface (overlay, 0, 0)
ctx.paint()
- #ctx.show_surface(overlay, width, height)
+
+def expose(drawingarea, event):
+ ctx = cairo.gtk.create_cairo_context(drawingarea.window)
+
+ draw (ctx, drawingarea.allocation.width, drawingarea.allocation.height)
+
+ return False
+
+
def main():
win = gtk.Window()
win.connect('destroy', gtk.main_quit)
- Previous message: [cairo-commit] pycairo/examples warpedtext.py,1.10,1.11
- Next message: [cairo-commit] pycairo/cairo cairogtkmodule.c, 1.18,
1.19 cairomodule.c, 1.30, 1.31 cairosvgmodule.c, 1.3,
1.4 pycairo-context.c, 1.46, 1.47 pycairo-font.c, 1.13,
1.14 pycairo-matrix.c, 1.14, 1.15 pycairo-misc.h, 1.1,
1.2 pycairo-path.c, NONE, 1.1 pycairo-pattern.c, 1.17,
1.18 pycairo-private.h, 1.20, 1.21 pycairo-surface.c, 1.34,
1.35 pycairo.h, 1.27, 1.28 pycairosvg-context.c, 1.4,
1.5 pycairosvg-private.h, 1.2, 1.3 Makefile.am, 1.11, 1.12
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list