[cairo-commit] [cairo-www] src/pycairo.mdwn

Carl Worth cworth at freedesktop.org
Wed Jul 4 13:40:39 PDT 2007


 src/pycairo.mdwn |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

New commits:
commit 1191b55f0d8d732401e7405d1103c564e45e5046
Author: vchahun <vchahun at gmail.com>
Date:   Wed Jul 4 13:40:39 2007 -0700

    Small linking method change

diff --git a/src/pycairo.mdwn b/src/pycairo.mdwn
index ae69669..d655a03 100644
--- a/src/pycairo.mdwn
+++ b/src/pycairo.mdwn
@@ -25,6 +25,35 @@ useful. There is also a NOTES file in the tarball release which lists
 how Pycairo differs from the cairo C API, and there are Pycairo
 examples in the examples/ directory of the tarball release.
 
+# Example
+
+This simple examples draws a blue triangle into a png file.
+
+	import cairo
+
+	width,height = 400,400
+
+	# Cairo Setup
+
+	surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) # Drawing surface
+	ctx = cairo.Context(surface) # Drawing context
+
+	# Triangle
+
+	ctx.move_to(200,100)
+	ctx.line_to(300,300)
+	ctx.rel_line_to(-200,0)
+	ctx.close_path()
+
+	ctx.set_line_width(15) # Set thickness of brush
+	ctx.set_source_rgb(0.1, 0.1, 0.5) # Set stroke color
+	ctx.stroke() # Stroke path
+
+	# Output to PNG
+	surface.write_to_png("example.png")
+
+Several other [[Ressources|pycairo/ressources]] are available.
+
 # License
 
 Pycairo is [free


More information about the cairo-commit mailing list