[cairo-commit] pycairo/examples cairo-demo.py, 1.3, 1.4 hering.py, 1.1, 1.2 spiral.py, 1.1, 1.2

Steve Chaplin commit at pdx.freedesktop.org
Thu Nov 11 07:32:14 PST 2004


Committed by: stevech1097

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

Modified Files:
	cairo-demo.py hering.py spiral.py 
Log Message:
SC 11/11/2004

Index: cairo-demo.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo-demo.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo-demo.py	14 Nov 2003 15:32:10 -0000	1.3
+++ cairo-demo.py	11 Nov 2004 15:32:12 -0000	1.4
@@ -1,9 +1,11 @@
 #!/usr/bin/env python
+"""Based on cairo-demo/X11/cairo-demo.c
+"""
 import gtk
 import cairo
 import cairo.gtk
 
-SIZE = 40
+SIZE = 30
 
 def triangle(ctx):
     ctx.move_to(SIZE, 0)
@@ -106,13 +108,15 @@
     fill_shapes(ctx, 0, 12*SIZE)
 
     ctx.set_line_join(cairo.LINE_JOIN_BEVEL)
-    fill_shapes(ctx, 0, 25*SIZE)
+    fill_shapes(ctx, 0, 15*SIZE)
+    ctx.set_rgb_color(1,0,0)
+    stroke_shapes(ctx, 0, 15*SIZE)
 
 def main():
     win = gtk.Window()
-    win.connect('destroy', gtk.mainquit)
+    win.connect('destroy', lambda x: gtk.main_quit())
     win.set_title('Python Cairo Demo')
-    win.set_default_size(400, 400)
+    win.set_default_size(450, 550)
 
     drawingarea = gtk.DrawingArea()
     drawingarea.connect('expose_event', expose)

Index: hering.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/hering.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hering.py	3 Nov 2004 01:24:06 -0000	1.1
+++ hering.py	11 Nov 2004 15:32:12 -0000	1.2
@@ -57,4 +57,3 @@
 draw_hering (ctx, WIDTH, HEIGHT)
 
 ctx.show_page()
-fileObject.close()

Index: spiral.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/spiral.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- spiral.py	3 Nov 2004 01:24:06 -0000	1.1
+++ spiral.py	11 Nov 2004 15:32:12 -0000	1.2
@@ -5,9 +5,9 @@
 
 import cairo
 
-DPI = 72.0
-PAGE_W_IN, PAGE_H_IN = 8.5, 11.0
+PPI = 300
 WIDTH_IN, HEIGHT_IN = 4, 4
+WIDTH, HEIGHT = WIDTH_IN * 96.0, HEIGHT_IN * 96.0
 
 def draw_spiral (ctx, width, height):
     wd = .02 * width
@@ -33,20 +33,12 @@
     raise SystemExit("%s: %s" % (exc.filename, exc.strerror))
 
 ctx = cairo.Context()
-ctx.set_target_ps (fileObject, PAGE_W_IN, PAGE_H_IN, DPI, DPI)
-
-# center on page
-tx = (PAGE_W_IN - WIDTH_IN ) * DPI / 2.0
-ty = (PAGE_H_IN - HEIGHT_IN) * DPI / 2.0
-matrix = cairo.Matrix (tx=tx, ty=ty)
-ctx.set_matrix (matrix)
+ctx.set_target_ps (fileObject, WIDTH_IN, HEIGHT_IN, PPI, PPI)
 
-width, height = WIDTH_IN *DPI, HEIGHT_IN *DPI
-ctx.rectangle (0, 0, width, height)
+ctx.rectangle (0, 0, WIDTH, HEIGHT)
 ctx.set_rgb_color (1, 1, 1)
 ctx.fill()
 
-draw_spiral (ctx, width, height)
+draw_spiral (ctx, WIDTH, HEIGHT)
 
 ctx.show_page()
-fileObject.close()




More information about the cairo-commit mailing list