[cairo-commit] pycairo/examples/cairo_snippets/snippets clip_image.py, NONE, 1.1 image.py, NONE, 1.1 imagepattern.py, NONE, 1.1 clip.py, 1.2, 1.3

Steve Chaplin commit at pdx.freedesktop.org
Sun May 15 18:05:30 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/examples/cairo_snippets/snippets
In directory gabe:/tmp/cvs-serv26464/examples/cairo_snippets/snippets

Modified Files:
	clip.py 
Added Files:
	clip_image.py image.py imagepattern.py 
Log Message:
SC

--- NEW FILE: clip_image.py ---
snippet_normalize (cr, width, height)

cr.arc (0.5, 0.5, 0.3, 0, 2*M_PI)
cr.clip ()

image = cairo.ImageSurface.create_from_png ("data/romedalen.png")
w = image.width
h = image.height

cr.scale (1.0/w, 1.0/h)

cr.set_source_surface (image, 0, 0)
cr.paint ()

--- NEW FILE: image.py ---
snippet_normalize (cr, width, height)

image = cairo.ImageSurface.create_from_png ("data/romedalen.png")
w = image.width
h = image.height

cr.translate (0.5, 0.5)
cr.rotate (45* M_PI/180)
cr.scale  (1.0/w, 1.0/h)
cr.translate (-0.5*w, -0.5*h)

cr.set_source_surface (image, 0, 0)
cr.paint ()


--- NEW FILE: imagepattern.py ---
import math

snippet_normalize (cr, width, height)

image = cairo.ImageSurface.create_from_png ("data/romedalen.png")
w = image.width
h = image.height

pattern = cairo.Pattern.create_for_surface (image)
pattern.set_extend (cairo.EXTEND_REPEAT)

cr.translate (0.5, 0.5)
cr.rotate (M_PI / 4)
cr.scale (1 / math.sqrt (2), 1 / math.sqrt (2))
cr.translate (- 0.5, - 0.5)

matrix = cairo.Matrix(xx=w * 5, yy=h * 5) 
pattern.set_matrix (matrix)

cr.set_source (pattern)

cr.rectangle (0, 0, 1.0, 1.0)
cr.fill ()

Index: clip.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets/clip.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- clip.py	15 Apr 2005 03:25:37 -0000	1.2
+++ clip.py	16 May 2005 01:05:28 -0000	1.3
@@ -3,8 +3,6 @@
 cr.arc (0.5, 0.5, 0.3, 0, 2 * M_PI)
 cr.clip ()
 
-cr.new_path ()  #/* current path is not
-                #      consumed by cairo_clip() */
 cr.rectangle (0, 0, 1, 1)
 cr.fill ()
 cr.set_source_rgb (0, 1, 0)




More information about the cairo-commit mailing list