[cairo-commit] [cairo-www] src/animationrotation.mdwn src/cookbook src/dotnet-gdi-rendering.mdwn src/emboss.mdwn src/freetypepython.mdwn src/gdkpixbufpycairo.mdwn src/hittestpython.mdwn src/matrix_conventions src/matrix_conventions.mdwn src/matrix_transform src/matrix_transform.mdwn src/perl_cairo_module.mdwn src/pycairo_pango.mdwn src/pyrsvg.mdwn src/pythoncairopil.mdwn src/quickframework.mdwn src/renderpdf.mdwn src/svgtopycairo.mdwn src/win32quickstart.mdwn

Nis Martensen nmartensen at freedesktop.org
Fri Nov 20 12:39:38 PST 2015


 dev/null                                                |binary
 src/animationrotation.mdwn                              |  387 ----------------
 src/cookbook/animationrotation.mdwn                     |  387 ++++++++++++++++
 src/cookbook/dotnet-gdi-rendering.mdwn                  |   47 +
 src/cookbook/emboss.c.mdwn                              |    1 
 src/cookbook/emboss.mdwn                                |  159 ++++++
 src/cookbook/freetypepython.mdwn                        |   89 +++
 src/cookbook/gdkpixbufpycairo.mdwn                      |   40 +
 src/cookbook/hittestpython.mdwn                         |  200 ++++++++
 src/cookbook/matrix_conventions.mdwn                    |   86 +++
 src/cookbook/matrix_conventions/figure_1.png            |binary
 src/cookbook/matrix_conventions/figure_2.png            |binary
 src/cookbook/matrix_conventions/figure_3.png            |binary
 src/cookbook/matrix_conventions/figure_4.png            |binary
 src/cookbook/matrix_transform.mdwn                      |   33 +
 src/cookbook/matrix_transform/matrix_multiplication.gif |binary
 src/cookbook/perl_cairo_module.mdwn                     |   75 +++
 src/cookbook/pycairo_pango.mdwn                         |   62 ++
 src/cookbook/pyrsvg.mdwn                                |  126 +++++
 src/cookbook/pythoncairopil.mdwn                        |   21 
 src/cookbook/quickframework.mdwn                        |   70 ++
 src/cookbook/renderpdf.mdwn                             |  200 ++++++++
 src/cookbook/svgtopycairo.mdwn                          |  152 ++++++
 src/dotnet-gdi-rendering.mdwn                           |   47 -
 src/emboss.mdwn                                         |  159 ------
 src/freetypepython.mdwn                                 |   89 ---
 src/gdkpixbufpycairo.mdwn                               |   40 -
 src/hittestpython.mdwn                                  |  200 --------
 src/matrix_conventions.mdwn                             |   86 ---
 src/matrix_transform.mdwn                               |   33 -
 src/perl_cairo_module.mdwn                              |   75 ---
 src/pycairo_pango.mdwn                                  |   62 --
 src/pyrsvg.mdwn                                         |  126 -----
 src/pythoncairopil.mdwn                                 |   21 
 src/quickframework.mdwn                                 |   70 --
 src/renderpdf.mdwn                                      |  200 --------
 src/svgtopycairo.mdwn                                   |  152 ------
 src/win32quickstart.mdwn                                |  169 ------
 38 files changed, 1747 insertions(+), 1917 deletions(-)

New commits:
commit 6d236546b809ae8747551d4dcb173f876e69caf0
Author: Lawrence D'Oliveiro <ldo at geek-central.gen.nz>
Date:   Thu Nov 19 23:22:21 2015 +0000

    move all cookbook samples into cookbook subdirectory and remove unused blank file

diff --git a/src/animationrotation.mdwn b/src/animationrotation.mdwn
deleted file mode 100644
index f0b4938..0000000
--- a/src/animationrotation.mdwn
+++ /dev/null
@@ -1,387 +0,0 @@
-## A pyCairo/PyGTK animation framework
-
-There are two demos now, the first shows (gasp) a square rotating around an arbitrary point. Scroll down for the second one which is longer and a bit more interesting.
-
-This demo is two things: First it's a nice little framework that gives "life" to a function so that animation becomes possible. If you want stuff to be drawn again and again with little changes, this is a good start. (I'd love to see other solutions). 
- Secondly it shows how to rotate a "shape" (set of cairo commands) around any given ( x, y ) point.
-
-I tried to comment it thoroughly, so it will 'splain itself.
-
-
-    ##    cairo demos Copyright  (C)  2007 Donn.C.Ingle
-    ##
-    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
-    ##
-    ##    This program is free software; you can redistribute it and/or modify
-    ##    it under the terms of the GNU General Public License as published by
-    ##    the Free Software Foundation; either version 2 of the License, or
-    ##     ( at your option )  any later version.
-    ##
-    ##    This program is distributed in the hope that it will be useful,
-    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    ##    GNU General Public License for more details.
-    ##
-    ##    You should have received a copy of the GNU General Public License
-    ##    along with this program; if not, write to the Free Software
-    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    import pygtk
-    import gtk, gobject, cairo
-    from gtk import gdk
-
-    class Screen( gtk.DrawingArea ):
-        """ This class is a Drawing Area"""
-        def __init__(self):
-            super(Screen,self).__init__()
-            ## Old fashioned way to connect expose. I don't savvy the gobject stuff.
-            self.connect ( "expose_event", self.do_expose_event )
-            ## This is what gives the animation life!
-            gobject.timeout_add( 50, self.tick ) # Go call tick every 50 whatsits.
-            
-        def tick ( self ):
-            ## This invalidates the screen, causing the expose event to fire.
-            self.alloc = self.get_allocation ( )
-            rect = gtk.gdk.Rectangle ( self.alloc.x, self.alloc.y, self.alloc.width, self.alloc.height )
-            self.window.invalidate_rect ( rect, True )        
-            return True # Causes timeout to tick again.
-        
-        ## When expose event fires, this is run
-        def do_expose_event( self, widget, event ):
-            self.cr = self.window.cairo_create( )
-            ## Call our draw function to do stuff.
-            self.draw( *self.window.get_size( ) )
-            
-    class MyStuff ( Screen ):
-        """This class is also a Drawing Area, coming from Screen."""
-        def __init__ ( self ):
-            Screen.__init__( self )
-            ## x,y is where I'm at
-            self.x, self.y = 25, -25
-            ## rx,ry is point of rotation
-            self.rx, self.ry = -10, -25
-            ## rot is angle counter
-            self.rot = 0
-            ## sx,sy is to mess with scale
-            self.sx, self.sy = 1, 1
-
-        def draw( self, width, height ):
-            ## A shortcut
-            cr = self.cr
-            
-            ## First, let's shift 0,0 to be in the center of page
-            ## This means:
-            ##  -y | -y
-            ##  -x | +x
-            ## ----0------
-            ##  -x | +x
-            ##  +y | +y
-            
-            matrix = cairo.Matrix ( 1, 0, 0, 1, width/2, height/2 )
-            cr.transform ( matrix ) # Make it so...
-            
-            ## Now save that situation so that we can mess with it.
-            ## This preserves the last context ( the one at 0,0)
-            ## and let's us do new stuff.
-            cr.save ( )
-            
-            ## Now attempt to rotate something around a point
-            ## Use a matrix to change the shape's position and rotation.
-            
-            ## First, make a matrix. Don't look at me, I only use this stuff :)
-            ThingMatrix = cairo.Matrix ( 1, 0, 0, 1, 0, 0 )
-            
-            ## Next, move the drawing to it's x,y
-            cairo.Matrix.translate ( ThingMatrix, self.x, self.y )
-            cr.transform ( ThingMatrix ) # Changes the context to reflect that
-            
-            ## Now, change the matrix again to:
-            cairo.Matrix.translate( ThingMatrix, self.rx, self.ry ) # move it all to point of rotation
-            cairo.Matrix.rotate( ThingMatrix, self.rot ) # Do the rotation
-            cairo.Matrix.translate( ThingMatrix, -self.rx, -self.ry ) # move it back again
-            cairo.Matrix.scale( ThingMatrix, self.sx, self.sy ) # Now scale it all
-            cr.transform ( ThingMatrix ) # and commit it to the context
-
-            ## Now, whatever is draw is "under the influence" of the 
-            ## context and all that matrix magix we just did.
-            self.drawCairoStuff ( cr )
-            
-            ## Let's inc the angle a little
-            self.rot += 0.1
-            
-            ## Now mess with scale too
-            self.sx += 0 # Change to 0 to see if rotation is working...
-            if self.sx > 4: self.sx=0.5
-            self.sy = self.sx
-            
-            ## We restore to a clean context, to undo all that hocus-pocus
-            cr.restore ( )
-            
-            ## Let's draw a crosshair so we can identify 0,0
-            ## Drawn last to be above the red square.
-            self.drawcross ( cr )         
-            
-        def drawCairoStuff ( self, cr ):
-            ## Thrillingly, we draw a red rectangle.
-            ## It's drawn such that 0,0 is in it's center.
-            cr.rectangle( -25, -25, 50, 50 )
-            cr.set_source_rgb( 1, 0, 0) 
-            cr.fill( )
-            ## Now a visual indicator of the point of rotation
-            ## I have no idea (yet) how to keep this as a 
-            ## tiny dot when the entire thing scales.
-            cr.set_source_rgb( 1, 1, 1 )
-            cr.move_to( self.rx, self.ry )
-            cr.line_to ( self.rx+1, self.ry+1 )
-            cr.stroke( )
-            
-        def drawcross ( self, ctx ):
-            ## Also drawn around 0,0 in the center
-            ctx.set_source_rgb ( 0, 0, 0 )
-            ctx.move_to ( 0,10 )
-            ctx.line_to ( 0, -10 )
-            ctx.move_to ( -10, 0 )
-            ctx.line_to ( 10, 0 )
-            ctx.stroke ( )
-            
-            
-    def run( Widget ):
-        window = gtk.Window( )
-        window.connect( "delete-event", gtk.main_quit )
-        window.set_size_request ( 400, 400 )
-        widget = Widget( )
-        widget.show( )
-        window.add( widget )
-        window.present( )
-        gtk.main( )
-        
-    run( MyStuff )
-
-## Here's a longer version with many things moving
-
-I spent some time (and got some help from the list - thanks) working on a better version to demonstrate how to move many things around. This one also shows how you can use context.save() to create what I call "bubbles" of private space on the screen where different rules can apply for a short time. By putting bubbles within other bubbles you can create parent->child relationships. The sample has a red square that is a parent to a green one. What the red does, the green does too.
-
-This also shows primitive mouse hit detection (prints to the console, so hold onto your seats because the budget was just blown baby!) on the green square. 
-
-I hope this help someone out there.
-
-
-
-    ##    cairo demos Copyright  (C)  2007 Donn.C.Ingle
-    ##
-    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
-    ##
-    ##    This program is free software; you can redistribute it and/or modify
-    ##    it under the terms of the GNU General Public License as published by
-    ##    the Free Software Foundation; either version 2 of the License, or
-    ##     ( at your option )  any later version.
-    ##
-    ##    This program is distributed in the hope that it will be useful,
-    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    ##    GNU General Public License for more details.
-    ##
-    ##    You should have received a copy of the GNU General Public License
-    ##    along with this program; if not, write to the Free Software
-    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    import pygtk
-    import gtk, gobject, cairo
-    from gtk import gdk
-
-    class Screen( gtk.DrawingArea ):
-        """ This class is a Drawing Area"""
-        def __init__( self, w, h, speed ):
-            super( Screen, self ).__init__( )
-            ## Old fashioned way to connect expose. I don't savvy the gobject stuff.
-            self.connect ( "expose_event", self.do_expose_event )
-            ## We want to know where the mouse is:
-            self.connect ( "motion_notify_event", self._mouseMoved )
-            ## More GTK voodoo : unmask events
-            self.add_events ( gdk.BUTTON_PRESS_MASK |   gdk.BUTTON_RELEASE_MASK |   gdk.POINTER_MOTION_MASK )        
-            ## This is what gives the animation life!
-            gobject.timeout_add( speed, self.tick ) # Go call tick every 'speed' whatsits.
-            self.width, self.height = w, h
-            self.set_size_request ( w, h )
-            self.x, self.y = 11110,11111110 #unlikely first coord to prevent false hits.
-            
-        def tick ( self ):
-            """This invalidates the screen, causing the expose event to fire."""
-            self.alloc = self.get_allocation ( )
-            rect = gtk.gdk.Rectangle ( self.alloc.x, self.alloc.y, self.alloc.width, self.alloc.height )
-            self.window.invalidate_rect ( rect, True )        
-            return True # Causes timeout to tick again.
-        
-        ## When expose event fires, this is run
-        def do_expose_event( self, widget, event ):
-            self.cr = self.window.cairo_create( )
-            ## Call our draw function to do stuff.
-            self.draw( )
-            
-        def _mouseMoved ( self, widget, event ):
-            self.x = event.x
-            self.y = event.y
-            
-    class BunchOfStuff ( object ):
-        """Stores a bunch of data"""
-        def __init__ ( self, x=0, y=0, rx=0, ry=0, rot=0, sx=1, sy=1 ):
-            self.x = x
-            self.y = y
-            self.rx = rx
-            self.ry = ry
-            self.rot = rot
-            self.sx = sx
-            self.sy  = sy
-            
-    class MyStuff ( Screen ):
-        """This class is also a Drawing Area, coming from Screen."""
-        def __init__ ( self, w, h, speed):
-            Screen.__init__( self, w, h, speed )
-            
-            ## Setup three sets of data for the three objects to be drawn
-            self.red = BunchOfStuff ( x=50, y=-10, rx=50, ry=25 )
-            self.green = BunchOfStuff ( x=-10, y=10 )
-            self.blue = BunchOfStuff ( x=-70,y=30, sx=1, sy=1 )
-            
-            self.sign = +1 # to flip the blue animation's sign
-            
-        def setToCenter ( self ):
-            """Shift 0,0 to be in the center of page."""
-            matrix = cairo.Matrix ( 1, 0, 0, 1, self.width/2, self.height/2 )
-            self.cr.transform ( matrix ) # Make it so...
-        
-        def doMatrixVoodoo ( self, bos ):
-            """Do all the matrix mumbo to get stuff to the right place on the screen."""
-            ThingMatrix =cairo.Matrix ( 1, 0, 0, 1, 0, 0 )
-            ## Next, move the drawing to it's x,y
-            cairo.Matrix.translate ( ThingMatrix, bos.x, bos.y )
-            self.cr.transform ( ThingMatrix ) # Changes the context to reflect that
-            ## Now, change the matrix again to:
-            if bos.rx != 0 and bos.ry != 0 : # Only do this if there's a special reason
-                cairo.Matrix.translate( ThingMatrix, bos.rx, bos.ry ) # move it all to point of rotation
-            cairo.Matrix.rotate( ThingMatrix, bos.rot ) # Do the rotation
-            if bos.rx != 0 and bos.ry != 0 :        
-                cairo.Matrix.translate( ThingMatrix, -bos.rx, -bos.ry ) # move it back again
-            cairo.Matrix.scale( ThingMatrix, bos.sx, bos.sy ) # Now scale it all
-            self.cr.transform ( ThingMatrix ) # and commit it to the context
-
-        def draw( self ):
-            cr = self.cr # Shabby shortcut.
-            
-            #---------TOP LEVEL - THE "PAGE"
-            self.cr.identity_matrix  ( ) # VITAL LINE :: I'm not sure what it's doing.
-            self.setToCenter ( )
-            
-            #----------FIRST LEVEL
-            cr.save ( ) # Creates a 'bubble' of private coordinates. Save # 1
-           
-            ## RED - draw the red object
-            self.doMatrixVoodoo ( self.red )        
-            self.drawCairoStuff ( self.red  )
-            
-            #---------- SECOND LEVEL - RELATIVE TO FIRST
-            cr.save ( ) #save 2
-            
-            ## GREEN - draw the green one
-            self.doMatrixVoodoo ( self.green )
-            self.drawCairoStuff ( self.green, col= ( 0,1,0 )  )
-            
-            ## Demonstrate how to detect a mouse hit on this shape:
-            ## Draw the hit shape :: It *should* be drawn exactly over the green rectangle.
-            self.drawHitShape ( )
-            cr.save ( ) # Start a bubble
-            cr.identity_matrix ( ) # Reset the matrix within it.
-            hit = cr.in_fill ( self.x, self.y ) # Use Cairo's built-in hit test
-            cr.new_path ( ) # stops the hit shape from being drawn
-            cr.restore ( ) # Close the bubble like this never happened.
-            
-            
-            cr.restore ( ) #restore 2 :: "pop" the bubble.
-            
-            ## We are in level one's influence now
-            
-            cr.restore ( ) #restore 1
-            ## Back on PAGE's influence now
-            
-            #-------- THIRD LEVEL  -- RELATIVE TO PAGE
-            cr.save ( ) # Creates a 'bubble' of private coordinates.
-            ## Draw the blue object
-            self.doMatrixVoodoo ( self.blue ) # within the bubble, this will not effect the PAGE
-            self.drawCairoStuff ( self.blue, col= ( 0,0,1 )  )
-            cr.restore ( )
-            
-            ## Back on the PAGE level again.
-            
-            #indicate center
-            self.drawCrosshair ( )         
-            self.guageScale ( )
-            
-            ## Let's animate the red object 
-            ## ( which *also* moves the green because it's a 'child' 
-            ## of the red by way of being in the same "bubble" )
-            self.red.rot += 0.01
-            ## Now animate the blue
-            self.blue.sx += self.sign *  0.1
-            if  self.blue.sx < 0 or self.blue.sx > 4: 
-                self.sign *= -1
-            self.blue.sy = self.blue.sx
-            
-            ## Print to the console -- low-tech special effects :)
-            if hit: print "HIT!", self.x, self.y
-            
-        def guageScale ( self ):
-            """Draw some axis so we can see where stuff is."""
-            c = self.cr
-            m = 0
-            for x in range ( 10,210,10 ):
-                m += 1
-                w = 10 + ( m % 2 * 10 )
-                if x == 100: w = 50
-                c.rectangle ( x,-w/2,1,w )
-                c.rectangle ( -x, -w/2, 1, w )
-                c.rectangle ( -w/2, x, w, 1 )
-                c.rectangle ( -w/2, -x , w, 1 )
-            c.set_source_rgb ( 0,0,0 )
-            c.fill ( )
-            
-        def drawCairoStuff ( self, bos, col= ( 1,0,0 ) ):
-            """This draws the squares we see. Pass it a BagOfStuff (bos) and a colour."""
-            cr = self.cr
-            ## Thrillingly, we draw a rectangle.
-            ## It's drawn such that 0,0 is in it's center.
-            cr.rectangle( -25, -25, 50, 50 )
-            cr.set_source_rgb( col[0],col[1],col[2] ) 
-            cr.fill( )
-            ## Now draw an axis
-            self.guageScale ( )
-            ## Now a visual indicator of the point of rotation
-            cr.set_source_rgb( 1,1,1 )
-            cr.rectangle ( bos.rx - 2, bos.ry - 2, 4, 4 )
-            cr.fill ( )
-            
-        ## Same as the rectangle we see. No fill.
-        def drawHitShape ( self ):
-            """Draws a shape that we'll use to test hits."""
-            self.cr.rectangle( -25, -25, 50, 50 ) # Same as the shape of the squares
-            
-        def drawCrosshair ( self ):
-            """Another visual aid."""
-            ctx = self.cr
-            ctx.set_source_rgb ( 0, 0, 0 )
-            ctx.move_to ( 0,10 )
-            ctx.line_to ( 0, -10 )
-            ctx.move_to ( -10, 0 )
-            ctx.line_to ( 10, 0 )
-            ctx.stroke ( )
-            
-            
-    def run( Widget, w, h, speed ):
-        window = gtk.Window( )
-        window.connect( "delete-event", gtk.main_quit )
-        widget = Widget( w, h, speed )
-        widget.show( )
-        window.add( widget )
-        window.present( )
-        gtk.main( )
-        
-    run( MyStuff, 400, 400, speed = 20 )
diff --git a/src/cookbook/animationrotation.mdwn b/src/cookbook/animationrotation.mdwn
new file mode 100644
index 0000000..f0b4938
--- /dev/null
+++ b/src/cookbook/animationrotation.mdwn
@@ -0,0 +1,387 @@
+## A pyCairo/PyGTK animation framework
+
+There are two demos now, the first shows (gasp) a square rotating around an arbitrary point. Scroll down for the second one which is longer and a bit more interesting.
+
+This demo is two things: First it's a nice little framework that gives "life" to a function so that animation becomes possible. If you want stuff to be drawn again and again with little changes, this is a good start. (I'd love to see other solutions). 
+ Secondly it shows how to rotate a "shape" (set of cairo commands) around any given ( x, y ) point.
+
+I tried to comment it thoroughly, so it will 'splain itself.
+
+
+    ##    cairo demos Copyright  (C)  2007 Donn.C.Ingle
+    ##
+    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
+    ##
+    ##    This program is free software; you can redistribute it and/or modify
+    ##    it under the terms of the GNU General Public License as published by
+    ##    the Free Software Foundation; either version 2 of the License, or
+    ##     ( at your option )  any later version.
+    ##
+    ##    This program is distributed in the hope that it will be useful,
+    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    ##    GNU General Public License for more details.
+    ##
+    ##    You should have received a copy of the GNU General Public License
+    ##    along with this program; if not, write to the Free Software
+    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    import pygtk
+    import gtk, gobject, cairo
+    from gtk import gdk
+
+    class Screen( gtk.DrawingArea ):
+        """ This class is a Drawing Area"""
+        def __init__(self):
+            super(Screen,self).__init__()
+            ## Old fashioned way to connect expose. I don't savvy the gobject stuff.
+            self.connect ( "expose_event", self.do_expose_event )
+            ## This is what gives the animation life!
+            gobject.timeout_add( 50, self.tick ) # Go call tick every 50 whatsits.
+            
+        def tick ( self ):
+            ## This invalidates the screen, causing the expose event to fire.
+            self.alloc = self.get_allocation ( )
+            rect = gtk.gdk.Rectangle ( self.alloc.x, self.alloc.y, self.alloc.width, self.alloc.height )
+            self.window.invalidate_rect ( rect, True )        
+            return True # Causes timeout to tick again.
+        
+        ## When expose event fires, this is run
+        def do_expose_event( self, widget, event ):
+            self.cr = self.window.cairo_create( )
+            ## Call our draw function to do stuff.
+            self.draw( *self.window.get_size( ) )
+            
+    class MyStuff ( Screen ):
+        """This class is also a Drawing Area, coming from Screen."""
+        def __init__ ( self ):
+            Screen.__init__( self )
+            ## x,y is where I'm at
+            self.x, self.y = 25, -25
+            ## rx,ry is point of rotation
+            self.rx, self.ry = -10, -25
+            ## rot is angle counter
+            self.rot = 0
+            ## sx,sy is to mess with scale
+            self.sx, self.sy = 1, 1
+
+        def draw( self, width, height ):
+            ## A shortcut
+            cr = self.cr
+            
+            ## First, let's shift 0,0 to be in the center of page
+            ## This means:
+            ##  -y | -y
+            ##  -x | +x
+            ## ----0------
+            ##  -x | +x
+            ##  +y | +y
+            
+            matrix = cairo.Matrix ( 1, 0, 0, 1, width/2, height/2 )
+            cr.transform ( matrix ) # Make it so...
+            
+            ## Now save that situation so that we can mess with it.
+            ## This preserves the last context ( the one at 0,0)
+            ## and let's us do new stuff.
+            cr.save ( )
+            
+            ## Now attempt to rotate something around a point
+            ## Use a matrix to change the shape's position and rotation.
+            
+            ## First, make a matrix. Don't look at me, I only use this stuff :)
+            ThingMatrix = cairo.Matrix ( 1, 0, 0, 1, 0, 0 )
+            
+            ## Next, move the drawing to it's x,y
+            cairo.Matrix.translate ( ThingMatrix, self.x, self.y )
+            cr.transform ( ThingMatrix ) # Changes the context to reflect that
+            
+            ## Now, change the matrix again to:
+            cairo.Matrix.translate( ThingMatrix, self.rx, self.ry ) # move it all to point of rotation
+            cairo.Matrix.rotate( ThingMatrix, self.rot ) # Do the rotation
+            cairo.Matrix.translate( ThingMatrix, -self.rx, -self.ry ) # move it back again
+            cairo.Matrix.scale( ThingMatrix, self.sx, self.sy ) # Now scale it all
+            cr.transform ( ThingMatrix ) # and commit it to the context
+
+            ## Now, whatever is draw is "under the influence" of the 
+            ## context and all that matrix magix we just did.
+            self.drawCairoStuff ( cr )
+            
+            ## Let's inc the angle a little
+            self.rot += 0.1
+            
+            ## Now mess with scale too
+            self.sx += 0 # Change to 0 to see if rotation is working...
+            if self.sx > 4: self.sx=0.5
+            self.sy = self.sx
+            
+            ## We restore to a clean context, to undo all that hocus-pocus
+            cr.restore ( )
+            
+            ## Let's draw a crosshair so we can identify 0,0
+            ## Drawn last to be above the red square.
+            self.drawcross ( cr )         
+            
+        def drawCairoStuff ( self, cr ):
+            ## Thrillingly, we draw a red rectangle.
+            ## It's drawn such that 0,0 is in it's center.
+            cr.rectangle( -25, -25, 50, 50 )
+            cr.set_source_rgb( 1, 0, 0) 
+            cr.fill( )
+            ## Now a visual indicator of the point of rotation
+            ## I have no idea (yet) how to keep this as a 
+            ## tiny dot when the entire thing scales.
+            cr.set_source_rgb( 1, 1, 1 )
+            cr.move_to( self.rx, self.ry )
+            cr.line_to ( self.rx+1, self.ry+1 )
+            cr.stroke( )
+            
+        def drawcross ( self, ctx ):
+            ## Also drawn around 0,0 in the center
+            ctx.set_source_rgb ( 0, 0, 0 )
+            ctx.move_to ( 0,10 )
+            ctx.line_to ( 0, -10 )
+            ctx.move_to ( -10, 0 )
+            ctx.line_to ( 10, 0 )
+            ctx.stroke ( )
+            
+            
+    def run( Widget ):
+        window = gtk.Window( )
+        window.connect( "delete-event", gtk.main_quit )
+        window.set_size_request ( 400, 400 )
+        widget = Widget( )
+        widget.show( )
+        window.add( widget )
+        window.present( )
+        gtk.main( )
+        
+    run( MyStuff )
+
+## Here's a longer version with many things moving
+
+I spent some time (and got some help from the list - thanks) working on a better version to demonstrate how to move many things around. This one also shows how you can use context.save() to create what I call "bubbles" of private space on the screen where different rules can apply for a short time. By putting bubbles within other bubbles you can create parent->child relationships. The sample has a red square that is a parent to a green one. What the red does, the green does too.
+
+This also shows primitive mouse hit detection (prints to the console, so hold onto your seats because the budget was just blown baby!) on the green square. 
+
+I hope this help someone out there.
+
+
+
+    ##    cairo demos Copyright  (C)  2007 Donn.C.Ingle
+    ##
+    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
+    ##
+    ##    This program is free software; you can redistribute it and/or modify
+    ##    it under the terms of the GNU General Public License as published by
+    ##    the Free Software Foundation; either version 2 of the License, or
+    ##     ( at your option )  any later version.
+    ##
+    ##    This program is distributed in the hope that it will be useful,
+    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    ##    GNU General Public License for more details.
+    ##
+    ##    You should have received a copy of the GNU General Public License
+    ##    along with this program; if not, write to the Free Software
+    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    import pygtk
+    import gtk, gobject, cairo
+    from gtk import gdk
+
+    class Screen( gtk.DrawingArea ):
+        """ This class is a Drawing Area"""
+        def __init__( self, w, h, speed ):
+            super( Screen, self ).__init__( )
+            ## Old fashioned way to connect expose. I don't savvy the gobject stuff.
+            self.connect ( "expose_event", self.do_expose_event )
+            ## We want to know where the mouse is:
+            self.connect ( "motion_notify_event", self._mouseMoved )
+            ## More GTK voodoo : unmask events
+            self.add_events ( gdk.BUTTON_PRESS_MASK |   gdk.BUTTON_RELEASE_MASK |   gdk.POINTER_MOTION_MASK )        
+            ## This is what gives the animation life!
+            gobject.timeout_add( speed, self.tick ) # Go call tick every 'speed' whatsits.
+            self.width, self.height = w, h
+            self.set_size_request ( w, h )
+            self.x, self.y = 11110,11111110 #unlikely first coord to prevent false hits.
+            
+        def tick ( self ):
+            """This invalidates the screen, causing the expose event to fire."""
+            self.alloc = self.get_allocation ( )
+            rect = gtk.gdk.Rectangle ( self.alloc.x, self.alloc.y, self.alloc.width, self.alloc.height )
+            self.window.invalidate_rect ( rect, True )        
+            return True # Causes timeout to tick again.
+        
+        ## When expose event fires, this is run
+        def do_expose_event( self, widget, event ):
+            self.cr = self.window.cairo_create( )
+            ## Call our draw function to do stuff.
+            self.draw( )
+            
+        def _mouseMoved ( self, widget, event ):
+            self.x = event.x
+            self.y = event.y
+            
+    class BunchOfStuff ( object ):
+        """Stores a bunch of data"""
+        def __init__ ( self, x=0, y=0, rx=0, ry=0, rot=0, sx=1, sy=1 ):
+            self.x = x
+            self.y = y
+            self.rx = rx
+            self.ry = ry
+            self.rot = rot
+            self.sx = sx
+            self.sy  = sy
+            
+    class MyStuff ( Screen ):
+        """This class is also a Drawing Area, coming from Screen."""
+        def __init__ ( self, w, h, speed):
+            Screen.__init__( self, w, h, speed )
+            
+            ## Setup three sets of data for the three objects to be drawn
+            self.red = BunchOfStuff ( x=50, y=-10, rx=50, ry=25 )
+            self.green = BunchOfStuff ( x=-10, y=10 )
+            self.blue = BunchOfStuff ( x=-70,y=30, sx=1, sy=1 )
+            
+            self.sign = +1 # to flip the blue animation's sign
+            
+        def setToCenter ( self ):
+            """Shift 0,0 to be in the center of page."""
+            matrix = cairo.Matrix ( 1, 0, 0, 1, self.width/2, self.height/2 )
+            self.cr.transform ( matrix ) # Make it so...
+        
+        def doMatrixVoodoo ( self, bos ):
+            """Do all the matrix mumbo to get stuff to the right place on the screen."""
+            ThingMatrix =cairo.Matrix ( 1, 0, 0, 1, 0, 0 )
+            ## Next, move the drawing to it's x,y
+            cairo.Matrix.translate ( ThingMatrix, bos.x, bos.y )
+            self.cr.transform ( ThingMatrix ) # Changes the context to reflect that
+            ## Now, change the matrix again to:
+            if bos.rx != 0 and bos.ry != 0 : # Only do this if there's a special reason
+                cairo.Matrix.translate( ThingMatrix, bos.rx, bos.ry ) # move it all to point of rotation
+            cairo.Matrix.rotate( ThingMatrix, bos.rot ) # Do the rotation
+            if bos.rx != 0 and bos.ry != 0 :        
+                cairo.Matrix.translate( ThingMatrix, -bos.rx, -bos.ry ) # move it back again
+            cairo.Matrix.scale( ThingMatrix, bos.sx, bos.sy ) # Now scale it all
+            self.cr.transform ( ThingMatrix ) # and commit it to the context
+
+        def draw( self ):
+            cr = self.cr # Shabby shortcut.
+            
+            #---------TOP LEVEL - THE "PAGE"
+            self.cr.identity_matrix  ( ) # VITAL LINE :: I'm not sure what it's doing.
+            self.setToCenter ( )
+            
+            #----------FIRST LEVEL
+            cr.save ( ) # Creates a 'bubble' of private coordinates. Save # 1
+           
+            ## RED - draw the red object
+            self.doMatrixVoodoo ( self.red )        
+            self.drawCairoStuff ( self.red  )
+            
+            #---------- SECOND LEVEL - RELATIVE TO FIRST
+            cr.save ( ) #save 2
+            
+            ## GREEN - draw the green one
+            self.doMatrixVoodoo ( self.green )
+            self.drawCairoStuff ( self.green, col= ( 0,1,0 )  )
+            
+            ## Demonstrate how to detect a mouse hit on this shape:
+            ## Draw the hit shape :: It *should* be drawn exactly over the green rectangle.
+            self.drawHitShape ( )
+            cr.save ( ) # Start a bubble
+            cr.identity_matrix ( ) # Reset the matrix within it.
+            hit = cr.in_fill ( self.x, self.y ) # Use Cairo's built-in hit test
+            cr.new_path ( ) # stops the hit shape from being drawn
+            cr.restore ( ) # Close the bubble like this never happened.
+            
+            
+            cr.restore ( ) #restore 2 :: "pop" the bubble.
+            
+            ## We are in level one's influence now
+            
+            cr.restore ( ) #restore 1
+            ## Back on PAGE's influence now
+            
+            #-------- THIRD LEVEL  -- RELATIVE TO PAGE
+            cr.save ( ) # Creates a 'bubble' of private coordinates.
+            ## Draw the blue object
+            self.doMatrixVoodoo ( self.blue ) # within the bubble, this will not effect the PAGE
+            self.drawCairoStuff ( self.blue, col= ( 0,0,1 )  )
+            cr.restore ( )
+            
+            ## Back on the PAGE level again.
+            
+            #indicate center
+            self.drawCrosshair ( )         
+            self.guageScale ( )
+            
+            ## Let's animate the red object 
+            ## ( which *also* moves the green because it's a 'child' 
+            ## of the red by way of being in the same "bubble" )
+            self.red.rot += 0.01
+            ## Now animate the blue
+            self.blue.sx += self.sign *  0.1
+            if  self.blue.sx < 0 or self.blue.sx > 4: 
+                self.sign *= -1
+            self.blue.sy = self.blue.sx
+            
+            ## Print to the console -- low-tech special effects :)
+            if hit: print "HIT!", self.x, self.y
+            
+        def guageScale ( self ):
+            """Draw some axis so we can see where stuff is."""
+            c = self.cr
+            m = 0
+            for x in range ( 10,210,10 ):
+                m += 1
+                w = 10 + ( m % 2 * 10 )
+                if x == 100: w = 50
+                c.rectangle ( x,-w/2,1,w )
+                c.rectangle ( -x, -w/2, 1, w )
+                c.rectangle ( -w/2, x, w, 1 )
+                c.rectangle ( -w/2, -x , w, 1 )
+            c.set_source_rgb ( 0,0,0 )
+            c.fill ( )
+            
+        def drawCairoStuff ( self, bos, col= ( 1,0,0 ) ):
+            """This draws the squares we see. Pass it a BagOfStuff (bos) and a colour."""
+            cr = self.cr
+            ## Thrillingly, we draw a rectangle.
+            ## It's drawn such that 0,0 is in it's center.
+            cr.rectangle( -25, -25, 50, 50 )
+            cr.set_source_rgb( col[0],col[1],col[2] ) 
+            cr.fill( )
+            ## Now draw an axis
+            self.guageScale ( )
+            ## Now a visual indicator of the point of rotation
+            cr.set_source_rgb( 1,1,1 )
+            cr.rectangle ( bos.rx - 2, bos.ry - 2, 4, 4 )
+            cr.fill ( )
+            
+        ## Same as the rectangle we see. No fill.
+        def drawHitShape ( self ):
+            """Draws a shape that we'll use to test hits."""
+            self.cr.rectangle( -25, -25, 50, 50 ) # Same as the shape of the squares
+            
+        def drawCrosshair ( self ):
+            """Another visual aid."""
+            ctx = self.cr
+            ctx.set_source_rgb ( 0, 0, 0 )
+            ctx.move_to ( 0,10 )
+            ctx.line_to ( 0, -10 )
+            ctx.move_to ( -10, 0 )
+            ctx.line_to ( 10, 0 )
+            ctx.stroke ( )
+            
+            
+    def run( Widget, w, h, speed ):
+        window = gtk.Window( )
+        window.connect( "delete-event", gtk.main_quit )
+        widget = Widget( w, h, speed )
+        widget.show( )
+        window.add( widget )
+        window.present( )
+        gtk.main( )
+        
+    run( MyStuff, 400, 400, speed = 20 )
diff --git a/src/cookbook/dotnet-gdi-rendering.mdwn b/src/cookbook/dotnet-gdi-rendering.mdwn
new file mode 100644
index 0000000..c01a67a
--- /dev/null
+++ b/src/cookbook/dotnet-gdi-rendering.mdwn
@@ -0,0 +1,47 @@
+Using GDI+ Bitmap as surface can be as simple as that (given in managed C++):
+
+	// Create the target bitmap to draw to.
+	Drawing::Bitmap contentBitmap= new Drawing::Bitmap(Width, Height);
+
+	// Create a Graphics object to have a device context we can pass to cairo.
+	Graphics^ g = Graphics::FromImage(contentBitmap);
+	g->SmoothingMode = SmoothingMode::HighQuality;
+
+	// Do some drawing in GDI+ to have some initial content, like:
+	// Fill interior.
+	Brush^ brush = gcnew SolidBrush(Color::FromArgb(191, 1, 0, 0));
+	g->FillPath(brush, innerPath);
+	delete brush;
+
+	// Get the device context handle from this graphics object and create a Win32 cairo surface from it.
+	IntPtr hdc= g->GetHdc();
+	cairo_surface_t* surface= cairo_win32_surface_create((HDC) hdc.ToPointer());
+
+	// For drawing we need a cairo context.
+	cairo_t* cr= cairo_create(surface);
+
+	// Now you are ready to draw to that using any of the cairo calls.
+	...
+
+	// Don't forget the cleanup.
+	cairo_destroy(cr);
+	cairo_surface_destroy(surface);
+
+	g->ReleaseHdc(hdc);
+
+This works quite well but has one big disadvantage: `cairo_win32_surface_create()` always returns a 24bit surface. So what if we have a bitmap with an alpha channel (like a png image we loaded and want to add something to it)? With the code above the alpha channel used in your cairo commands is lost.
+
+One could create a 32bit DIB surface (using `cairo_win32_surface_create_with_dib()`), but that creates a **separate** surface, which needs to be merged later to your actual target. Using an API like AlphaBlend (via pinvoke) produces exactly the same result as in the code above. So this is no help either.
+
+The solution for this dilemma is an image surface (e.g. you get an image surface when you load png images in cairo).
+
+	// Instead of getting an HDC and and use cairo_win32_surface we get directly
+	// to the pixels in the bitmap and create the image surface from that.
+	Imaging::BitmapData^ bitmapData= contentBitmap->LockBits(Drawing::Rectangle(0, 0, Width, Height),
+	  Imaging::ImageLockMode::ReadWrite, contentBitmap->PixelFormat);
+	unsigned char* data= (unsigned char*) bitmapData->Scan0.ToPointer();
+	cairo_surface_t* surface= cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, Width, Height,
+	  bitmapData->Stride);
+
+	// The rest is the same as above, except we have to unlock the bits after we finished drawing.
+	contentBitmap->UnlockBits(bitmapData);
diff --git a/src/cookbook/emboss.c.mdwn b/src/cookbook/emboss.c.mdwn
deleted file mode 100644
index 8b13789..0000000
--- a/src/cookbook/emboss.c.mdwn
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/cookbook/emboss.mdwn b/src/cookbook/emboss.mdwn
new file mode 100644
index 0000000..0face4f
--- /dev/null
+++ b/src/cookbook/emboss.mdwn
@@ -0,0 +1,159 @@
+##Emboss a cairo surface
+
+This sample shows how to apply an emboss effect to a cairo A8 image surface.
+
+    /*
+    Adapted from "Fast Embossing Effects on Raster Image Data"
+
+	    Original code by: John Schlag, <jfs at kerner.com>
+	    Adapted code by: Jeremy Moles, <cubicool at gmail.com>
+
+    Found in the publication "Graphics Gems IV", Academic Press, 1994
+    */
+
+    #include <cairo.h>
+    #include <math.h>
+    #include <stdio.h>
+    #include <string.h>
+    #include <stdlib.h>
+
+    #define PIXEL_SCALE 255
+    #define WIDTH_45    1
+
+    /* This function will use an exisiting surface's data and create and NEW surface copy
+    // of that data which has the emboss lighting algorithm applied to it. */
+    static cairo_surface_t* _create_embossed_surface_from_surface(
+	    cairo_surface_t* surface,
+	    double           azimuth,
+	    double           elevation
+    ) {
+	    unsigned char* src    = cairo_image_surface_get_data(surface);
+	    unsigned int   width  = cairo_image_surface_get_width(surface);
+	    unsigned int   stride = cairo_image_surface_get_stride(surface);
+	    unsigned int   height = cairo_image_surface_get_height(surface);
+
+	    cairo_surface_t* dstSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, width, height);
+
+	    unsigned char* dst = cairo_image_surface_get_data(dstSurface);
+
+	    /* Compute the light vector from the input parameters.
+	    // Normalize the length to PIXEL_SCALE for fast shading calculation. */
+	    long Lx   = cos(azimuth) * cos(elevation) * PIXEL_SCALE;
+	    long Ly   = sin(azimuth) * cos(elevation) * PIXEL_SCALE;
+	    long Lz   = sin(elevation) * PIXEL_SCALE;
+	    long Nz   = (6 * 255) / WIDTH_45;
+	    long Nz2  = Nz * Nz;
+	    long NzLz = Nz * Lz;
+
+	    unsigned int y = 1;
+	    unsigned int x = 1;
+
+	    /* TODO: Would it be better to fill DST with SRC instead of the Lz value?
+	    // memcpy(dst, src, stride * height); */
+	    memset(dst, Lz, stride * height);
+
+	    for(y = 1; y < height - 2; y++) {
+		    for(x = 1; x < stride - 1; x++) {
+			    unsigned int   offset = (y * stride) + x;
+			    unsigned char* s1     = src + offset;
+			    unsigned char* s2     = s1 + stride;
+			    unsigned char* s3     = s2 + stride;
+			    unsigned char  shade  = 0;
+
+			    /* Compute the normal from the source. The type of the expression
+			    // before the cast is compiler dependent. In some cases the sum is
+			    // unsigned, in others it is signed. Ergo, cast to signed. */
+			    long Nx = (long)(s1[-1] + s2[-1] + s3[-1] - s1[1] - s2[1] - s3[1]);
+			    long Ny = (long)(s3[-1] + s3[0] + s3[1] - s1[-1] - s1[0] - s1[1]);
+
+			    long NdotL = Nx * Lx + Ny * Ly + NzLz;
+
+			    /* Shade with distant light source. */
+			    if(!Nx && !Ny) shade = Lz;
+
+			    else if(NdotL < 0) shade = 0;
+
+			    else shade = NdotL / sqrt(Nx * Nx + Ny * Ny + Nz2);
+
+			    *(dst + offset) = shade;
+		    }
+	    }
+
+	    return dstSurface;
+    }
+
+    /* This function only supports A8 surfaces at the moment, and delegates work to the
+    // similarly named function above. */
+    static cairo_surface_t* create_embossed_surface_from_surface(
+	    cairo_surface_t* surface,
+	    double           azimuth,
+	    double           elevation
+    ) {
+	    if(cairo_image_surface_get_format(surface) != CAIRO_FORMAT_A8) {
+		    printf("This example only supports embossing A8 surfaces.\n");
+		    printf("It shouldn't be too wildy hard to add other format types.\n");
+
+		    return 0;
+	    }
+
+	    else return _create_embossed_surface_from_surface(surface, azimuth, elevation);
+    }
+
+    int main(int argc, char** argv) {
+	    unsigned int w        = 400;
+	    unsigned int h        = 50;
+	    unsigned int textSize = 35;
+	    const char*  text     = "Cairo Emboss!!!";
+
+	    cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_A8, w, h);
+	    cairo_t*         cr      = cairo_create(surface);
+
+	    cairo_text_extents_t extents;
+
+	    if(argc != 3) {
+		    printf(
+			    "usage: %s <int> <int>\nThe two integral arguments passed in are "
+			    "the light azimuth and elevation values, in angles.\n",
+			    argv[0]
+		    );
+
+		    goto cleanup;
+	    }
+
+	    cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
+	    cairo_set_font_size(cr, textSize);
+	    cairo_text_extents(cr, text, &extents);
+
+	    cairo_move_to(
+		    cr,
+		    ((double)(w - extents.width) / 2.0f) - extents.x_bearing,
+		    (double)(h - extents.y_bearing) / 2.0f
+	    );
+
+	    cairo_show_text(cr, text);
+
+	    cairo_surface_t* emboss = create_embossed_surface_from_surface(
+		    surface, 
+		    atoi(argv[1]) * (M_PI / 180.0f),
+		    atoi(argv[2]) * (M_PI / 180.0f)
+	    );
+
+	    if(!emboss) {
+		    printf("Calling the emboss function failed; cleaning up and leaving.\n");
+
+		    goto cleanup;
+	    }
+
+	    cairo_surface_write_to_png(surface, "cairo_emboss_normal.png");
+	    cairo_surface_write_to_png(emboss, "cairo_emboss_embossed.png");
+
+	    printf("Wrote cairo_emboss_{normal,embossed}.png to your local directory.\n");
+
+	    cairo_surface_destroy(emboss);
+
+    cleanup:
+	    cairo_surface_destroy(surface);
+	    cairo_destroy(cr);
+
+	    return 0;
+    }
diff --git a/src/cookbook/freetypepython.mdwn b/src/cookbook/freetypepython.mdwn
new file mode 100644
index 0000000..a1a48de
--- /dev/null
+++ b/src/cookbook/freetypepython.mdwn
@@ -0,0 +1,89 @@
+[[!meta title="Loading fonts using FreeType for cairo use in Python"]]
+Back to [[cookbook]]
+
+The following snippet uses Python's ctypes module to load a font file using FreeType
+and create a cairo font face from it, using the cairo-ft API that is not part of pycairo yet.
+The resulting cairo font face however can be used normally with pycairo.
+
+
+	import ctypes
+	import cairo
+
+
+	_initialized = False
+	def create_cairo_font_face_for_file (filename, faceindex=0, loadoptions=0):
+		global _initialized
+		global _freetype_so
+		global _cairo_so
+		global _ft_lib
+		global _surface
+
+		CAIRO_STATUS_SUCCESS = 0
+		FT_Err_Ok = 0
+
+		if not _initialized:
+
+			# find shared objects
+			_freetype_so = ctypes.CDLL ("libfreetype.so.6")
+			_cairo_so = ctypes.CDLL ("libcairo.so.2")
+
+			_cairo_so.cairo_ft_font_face_create_for_ft_face.restype = ctypes.c_void_p
+			_cairo_so.cairo_ft_font_face_create_for_ft_face.argtypes = [ ctypes.c_void_p, ctypes.c_int ]
+			_cairo_so.cairo_set_font_face.argtypes = [ ctypes.c_void_p, ctypes.c_void_p ]
+			_cairo_so.cairo_font_face_status.argtypes = [ ctypes.c_void_p ]
+			_cairo_so.cairo_status.argtypes = [ ctypes.c_void_p ]
+
+			# initialize freetype
+			_ft_lib = ctypes.c_void_p ()
+			if FT_Err_Ok != _freetype_so.FT_Init_FreeType (ctypes.byref (_ft_lib)):
+			  raise "Error initialising FreeType library."
+
+			class PycairoContext(ctypes.Structure):
+			    _fields_ = [("PyObject_HEAD", ctypes.c_byte * object.__basicsize__),
+					("ctx", ctypes.c_void_p),
+					("base", ctypes.c_void_p)]
+
+			_surface = cairo.ImageSurface (cairo.FORMAT_A8, 0, 0)
+
+			_initialized = True
+
+		# create freetype face
+		ft_face = ctypes.c_void_p()
+		cairo_ctx = cairo.Context (_surface)
+		cairo_t = PycairoContext.from_address(id(cairo_ctx)).ctx
+
+		if FT_Err_Ok != _freetype_so.FT_New_Face (_ft_lib, filename, faceindex, ctypes.byref(ft_face)):
+			raise Exception("Error creating FreeType font face for " + filename)
+
+		# create cairo font face for freetype face
+		cr_face = _cairo_so.cairo_ft_font_face_create_for_ft_face (ft_face, loadoptions)
+		if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_font_face_status (cr_face):
+			raise Exception("Error creating cairo font face for " + filename)
+
+		_cairo_so.cairo_set_font_face (cairo_t, cr_face)
+		if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_status (cairo_t):
+			raise Exception("Error creating cairo font face for " + filename)
+
+		face = cairo_ctx.get_font_face ()
+
+		return face
+
+	if __name__ == '__main__':
+
+		face = create_cairo_font_face_for_file ("/usr/share/fonts/dejavu-lgc/DejaVuLGCSerif.ttf", 0)
+
+		surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 128, 128)
+
+		ctx = cairo.Context(surface)
+
+		ctx.set_font_face(face)
+		ctx.set_font_size(30)
+		ctx.move_to(0, 44)
+		ctx.show_text("Hello,")
+
+		ctx.move_to(30, 74)
+		ctx.show_text("world!")
+
+		del ctx
+
+		surface.write_to_png("hello.png")
diff --git a/src/cookbook/gdkpixbufpycairo.mdwn b/src/cookbook/gdkpixbufpycairo.mdwn
new file mode 100644
index 0000000..1eacc7f
--- /dev/null
+++ b/src/cookbook/gdkpixbufpycairo.mdwn
@@ -0,0 +1,40 @@
+[[!meta title="Loading images"]]
+Back to [[cookbook]]
+
+Based on the cworth recipe.
+Loads file in any gdk-pixbuf supported format (look into your gdk-pixbuf.loaders or run 'gdk-pixbuf-query-loaders | grep gtk20').
+Can be used as a very primitive image viewer.
+
+    #!/usr/bin/env python
+    import sys
+    import gtk
+    import cairo
+
+    def expose (da, event, pixbuf):
+      ctx = da.window.cairo_create()
+      # You can put ctx.scale(..) or ctx.rotate(..) here, if you need some
+      ctx.set_source_pixbuf(pixbuf,0,0)
+      ctx.paint()
+      ctx.stroke()
+
+    def main():
+      filename = sys.argv[1]
+      pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
+      imgw=pixbuf.get_width()
+      imgh=pixbuf.get_height()
+      win = gtk.Window()
+      win.connect('destroy', gtk.main_quit)
+      win.set_default_size(imgw, imgh)
+      da = gtk.DrawingArea()
+      win.add(da)
+      da.connect('expose_event', expose, pixbuf)
+      win.show_all()
+      gtk.main()
+
+    if __name__ == '__main__':
+      if len(sys.argv) != 2:
+        program = sys.argv[0]
+        print program +':', 'usage:', program, '<filename>'
+        sys.exit(0)
+      else:
+        main()
\ No newline at end of file
diff --git a/src/cookbook/hittestpython.mdwn b/src/cookbook/hittestpython.mdwn
new file mode 100644
index 0000000..6ea465f
--- /dev/null
+++ b/src/cookbook/hittestpython.mdwn
@@ -0,0 +1,200 @@
+## A quick recipe for testing a hit on an area.
+
+Once you've drawn something and **before** you cr.fill() or cr.stroke(), you can record the path to a list of points for later use. This recipe includes an algorithm to tell whether a point is within that path's area or not. It prints to the console, so it's not exactly bling, but it's pretty nifty for all that. Go see <http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/> for the theory behind the voodoo :)
+
+##Newsflash
+
+Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway. See code listing 2.
+
+    #! /usr/bin/env python
+
+    ##    hittest Copyright  (C)  2007 Donn.C.Ingle
+    ##
+    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
+    ##
+    ##    This program is free software; you can redistribute it and/or modify
+    ##    it under the terms of the GNU General Public License as published by
+    ##    the Free Software Foundation; either version 2 of the License, or
+    ##     ( at your option )  any later version.
+    ##
+    ##    This program is distributed in the hope that it will be useful,
+    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    ##    GNU General Public License for more details.
+    ##
+    ##    You should have received a copy of the GNU General Public License
+    ##    along with this program; if not, write to the Free Software
+    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+    ##
+
+    import pygtk
+    pygtk.require('2.0')
+    import gtk, gobject, cairo
+    from gtk import gdk
+    
+    # Create a GTK+ widget on which we will draw using Cairo
+    class Screen(gtk.DrawingArea):
+    
+        # Draw in response to an expose-event
+        __gsignals__ = { "expose-event": "override" }
+    
+        def __init__(self):
+            super(Screen,self).__init__()
+            # gtk.Widget signals
+            self.connect("button_press_event", self.button_press)
+            self.connect("button_release_event", self.button_release)
+            self.connect("motion_notify_event", self.motion_notify)
+            # More GTK voodoo : unmask events
+            self.add_events(gdk.BUTTON_PRESS_MASK |
+                            gdk.BUTTON_RELEASE_MASK |
+                            gdk.POINTER_MOTION_MASK)
+            
+        # Handle the expose-event by drawing
+        def do_expose_event(self, event):
+    
+            # Create the cairo context
+            cr = self.window.cairo_create()
+            self.hitpath = None #Is set later
+            
+            # Restrict Cairo to the exposed area; avoid extra work
+            cr.rectangle(event.area.x, event.area.y,
+                    event.area.width, event.area.height)
+            cr.clip()
+    
+            self.draw(cr, *self.window.get_size())
+            
+        def makeHitPath(self,cairopath):
+            ## Make a simpler list of tuples
+            
+            ##        Internally, a cairo path looks like this:
+            ##        (0, (10.0, 10.0))
+            ##        (1, (60.0, 10.0))
+            ##        (1, (60.0, 60.0))
+            ##        (1, (35.0, 60.0))
+            ##        (1, (35.0, 35.0))
+            ##        (1, (10.0, 35.0))
+            ##        (1, (10.0, 60.0))
+            ##        (1, (-40.0, 60.0))
+            ##        (3, ()) #want to ignore this one
+            ##        (0, (10.0, 10.0))        
+            
+            self.hitpath = []
+            for sub in cairopath:
+                if sub[1]: #kick out the close path () empty tuple
+                    self.hitpath.append(sub[1]) #list of tuples
+            
+        def draw(self, cr, width, height):
+            # Fill the background with gray
+            cr.set_source_rgb(0.5, 0.5, 0.5)
+            cr.rectangle(0, 0, width, height)
+            cr.fill()
+            
+        def hitTest(self,*p):
+            ## Code lifted from http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
+            ## converted to Python. I won't pretend I grok it at all, just glad it works!
+            ## Not sure how well it works yet, it might have edge flaws.
+            px = p[0]
+            py = p[1]
+            counter = i = xinters = 0
+            p1 = p2 = ()
+                
+            p1 = self.hitpath[0]
+            N = len(self.hitpath)
+            
+            # Mathemagic loop-de-loop
+            for i in range(0,N):
+                p2 = self.hitpath[i % N]
+                if py > min( p1[1] , p2[1] ):
+                    if py <= max( p1[1], p2[1] ):
+                        if px <= max( p1[0], p2[0] ):
+                            if p1[1] != p2[1]:
+                                xinters = ( py - p1[1] ) * ( p2[0] - p1[0] ) / ( p2[1] - p1[1] ) + p1[0]
+                                if p1[0] == p2[0] or px <= xinters: counter += 1
+                p1 = p2
+    
+            if counter % 2 == 0:
+                return "outside"
+            return "inside"
+            
+        def button_press(self,widget,event):
+            pass
+        def button_release(self,widget,event):
+            pass
+        def motion_notify(self,widget,event):
+            pass
+    
+    # GTK mumbo-jumbo to show the widget in a window and quit when it's closed
+    def run(Widget):
+        window = gtk.Window()
+        window.connect("delete-event", gtk.main_quit)
+        widget = Widget()
+        widget.show()
+        window.add(widget)
+        window.present()
+        gtk.main()
+    
+    class Shapes(Screen):
+        #Override the press event
+        def button_press(self,widget,event):
+            print self.hitTest(event.x, event.y)
+            
+        def draw(self, cr, width, height):
+            x = y = 10
+            sx = sy = 50
+            cr.move_to(x,y)
+            cr.line_to(x+sx,y)
+            cr.line_to(x+sx,y+sy)
+            cr.line_to(x+(sx/2),y+sy)
+            cr.line_to(x+(sx/2),y+(sy/2))
+            cr.line_to(x,y+(sy/2))
+            cr.line_to(x,y+sy)
+            cr.line_to(x-sx,y+sy)
+            cr.close_path()
+            cr.set_source_rgb(1,0,0)
+            
+            self.makeHitPath(cr.copy_path_flat()) #record the path to use as a hit area.
+            
+            cr.fill() #consumes the path, so get it before the fill
+            
+    
+    run(Shapes)
+
+##Code Listing 2 : It's already done.
+
+    ...snip
+
+    class Shapes(Screen):
+        
+        #Override the press event
+        def button_press(self,widget,event):
+
+            ## Gues what? Cairo had it built-in all along :)
+            ## You just need to keep a ref to the context.
+            ## I'm not sure if re-"drawing" the entire path, just so you can
+            ## test it for a hit is faster than the other version of this
+            ## script that uses a manual python-speed algorithm.
+
+            self.cr.append_path(self.hitpath) # re-gen the path
+            result = self.cr.in_fill(event.x, event.y) # Test it. Sweet.
+            print result
+            
+        def draw(self, cr, width, height):
+            x = y = 10
+            sx = sy = 50
+            cr.move_to(x,y)
+            cr.line_to(x+sx,y)
+            cr.line_to(x+sx,y+sy)
+            cr.line_to(x+(sx/2),y+sy)
+            cr.line_to(x+(sx/2),y+(sy/2))
+            cr.line_to(x,y+(sy/2))
+            cr.line_to(x,y+sy)
+            cr.line_to(x-sx,y+sy)
+            cr.close_path()
+            cr.set_source_rgb(1,0,0)
+            
+            self.hitpath = cr.copy_path_flat() #record the path to use as a hit area.
+            
+            cr.fill() #consumes the path, so get it before the fill
+            
+    
+    run(Shapes)
diff --git a/src/cookbook/matrix_conventions.mdwn b/src/cookbook/matrix_conventions.mdwn
new file mode 100644
index 0000000..938d695
--- /dev/null
+++ b/src/cookbook/matrix_conventions.mdwn
@@ -0,0 +1,86 @@
+Matrix transformations are very powerful and useful in computer graphics. But they can be tricky to get right. This article won’t talk about the detailed mathematics of matrices—you can find plenty of descriptions of that elsewhere—but about the practicalities of getting matrix transformations correct in your program code.
+
+First of all, let me offer two important rules when writing matrix-manipulation code:
+
+* **Rule 1: Pick a convention and stick to it.** There are two *self-consistent* ways to write down a matrix transformation that takes a vector in object space (the coordinates in which the object is defined) and transforms it to world space (the coordinates in which the object is viewed): either as *post*-multiplication on a *row* vector, *e.g.*:
+
+       object-space vector → matrix1 → matrix2 → world-space vector
+
+   or as *pre*-multiplication on a *column* vector, *e.g.*:
+
+       world-space vector ← matrix2 ← matrix1 ← object-space vector
+
+   It may look like the first form is more natural (the transformation sequence going left-to-right rather than right-to-left), but in fact most code uses the latter, and it is probably the more convenient form for trying to envision what is going on, as we will see shortly. But the most vital thing is to be *absolutely clear which convention is in effect*.
+
+* **Rule 2: Understand, don’t fiddle.** If your transformations are coming out wrong, *don’t try randomly fiddling with the order of the components to get them right*. You might succeed eventually, but it is quite possible that you made *two* mistakes somewhere that just happen to cancel out. While two wrongs may make a right in this case, you have set a trap for yourself if you (or someone else) have to make an adjustment later: you might try to change the angle of a rotation, for example, only to discover that it has the opposite effect from what you expected; or your *x*-and *y*-scaling might be the wrong way round. So always *try to understand why your transformations are in the order they are*. The effort spent up-front will help keep things less confusing later on.
+
+Now let me give a handy tip for trying to envision the effect of a sequence of matrix transformations. Assuming the usual pre-multiplication-of-column-vectors convention, we can imagine each matrix as a magic box that, when we look through it, transforms the appearance of space on the other side, making things bigger or smaller, rotating or repositioning them and so on. So if we represent object space by the object we are looking at (here a simple line-drawing of a teapot), ahd world space by the eye of the observer, then a transformation like
+
+    world-space vector ← matrix ← object-space vector
+
+can be visualized as
+
+<div align="center">
+[[!img "figure_1.png" link="no"]]
+</div>
+
+where the purple arrows show the flow of geometric information from object space (coordinate system (*x<sub>o</sub>*, *y<sub>o</sub>*)), through the matrix transformation box, to the observer’s eye (coordinate system (*x<sub>w</sub>*, *y<sub>w</sub>*)).
+
+The basic principles apply equally to both 2D and 3D graphics. Here we are dealing with 2D graphics in Cairo. The examples will be in Python, using the high-level [[Qahirah|https://github.com/ldo/qahirah]] binding. This lets us represent the transformation of a <tt>Vector</tt> object by a <tt>Matrix</tt> object directly as a simple Python expression:
+
+    user_space_coord = matrix * object_space_coord
+
+Let us envision what happens if we apply a simple rotational transform to the object.
+
+<div align="center">
+[[!img "figure_2.png" link="no"]]
+</div>
+
+By superimposing both coordinate systems in the upper part of the diagram (the current one in black, the previous one in grey), we can see the differing effects of, for example, moving parallel to the axes in object space coordinates (*x<sub>o</sub>*, *y<sub>o</sub>*) versus world space coordinates (*x<sub>w</sub>*, *y<sub>w</sub>*). In the Python code, we can spread things out across multiple lines, to more closely approximate the arrangement in the diagram:
+
+    user_space_coord = \
+        (
+            Matrix.rotate(45 * deg)
+        *
+            object_space_coord
+        )
+
+Now, what happens if we apply two transformations in succession?
+
+<div align="center">
+[[!img "figure_3.png" link="no"]]
+</div>
+
+Here the transformations (in order from object space to world space) are rotation about the origin, followed by translation along the positive *y*-axis. The rotation converts from object coordinates (*x<sub>o</sub>*, *y<sub>o</sub>*) to the intermediate coordinate system (*x<sub>m</sub>*, *y<sub>m</sub>*). The translation then converts from (*x<sub>m</sub>*, *y<sub>m</sub>*) to (*x<sub>w</sub>*, *y<sub>w</sub>*) coordinates. The equivalent Python code would be something like
+
+    user_space_coord = \
+        (
+            Matrix.translate((0, 10))
+        *
+            Matrix.rotate(45 * deg)
+        *
+            object_space_coord
+        )
+
+Here the order is reversed, the *y*-axis translation being applied first:
+
+<div align="center">
+[[!img "figure_4.png" link="no"]]
+</div>
+
+Thus, the rotation takes place, not about the (*x<sub>o</sub>*, *y<sub>o</sub>*) origin, but about the (*x<sub>m</sub>*, *y<sub>m</sub>*) origin.
+
+**Each transformation (blue background) is applied in the coordinate system of the picture of the object immediately below it (yellow background).**
+
+Note that, while the *orientation* of the teapot ends up the same in both these cases, its *position* is different. The equivalent Python code would be correspondingly rearranged to match the diagram:
+
+    user_space_coord = \
+        (
+            Matrix.rotate(45 * deg)
+        *
+            Matrix.translate((0, 10))
+        *
+            object_space_coord
+        )
+
+So, when you look at the Python code, imagine the eye of the observer on the receiving end of the value of the expression, at the top, while the object coordinates are at the bottom, being processed through successive stages of the transformation until they get to the top. Each individual  <tt>Matrix</tt> object corresponds to one of the boxes with a blue background, while the multiplication asterisk immediately below it corresponds to the picture with the yellow background immediately below that box.
diff --git a/src/cookbook/matrix_conventions/figure_1.png b/src/cookbook/matrix_conventions/figure_1.png
new file mode 100644
index 0000000..28c32ec
Binary files /dev/null and b/src/cookbook/matrix_conventions/figure_1.png differ
diff --git a/src/cookbook/matrix_conventions/figure_2.png b/src/cookbook/matrix_conventions/figure_2.png
new file mode 100644
index 0000000..2ce3ca8
Binary files /dev/null and b/src/cookbook/matrix_conventions/figure_2.png differ
diff --git a/src/cookbook/matrix_conventions/figure_3.png b/src/cookbook/matrix_conventions/figure_3.png
new file mode 100644
index 0000000..1177705
Binary files /dev/null and b/src/cookbook/matrix_conventions/figure_3.png differ
diff --git a/src/cookbook/matrix_conventions/figure_4.png b/src/cookbook/matrix_conventions/figure_4.png
new file mode 100644
index 0000000..7d108da
Binary files /dev/null and b/src/cookbook/matrix_conventions/figure_4.png differ
diff --git a/src/cookbook/matrix_transform.mdwn b/src/cookbook/matrix_transform.mdwn
new file mode 100644
index 0000000..93acde1
--- /dev/null
+++ b/src/cookbook/matrix_transform.mdwn
@@ -0,0 +1,33 @@
+This is some basic information about matrix transformation for people who forgot their math course or didn't have one.
+
+---
+
+Lets take that C = math.cos(A), S = math.sin(A), T = math.tan(A)
+
+mtrx have to be used in the command ctx.transform(mtrx)
+
+<table cellpadding="3" cellspacing="0" border="1" align="center">
+<tr align="center"><td>Action</td><td>Command</td><td>Matrix for transform</td></tr>
+<tr><td>Shift by dx,dy</td><td>ctx.translate(dx,dy)</td><td>mtrx = cairo.Matrix(1,0,0,1,dx,dy)</td></tr>
+<tr><td>Scale by fx,fy</td><td>ctx.scale(fx,fy)</td><td>mtrx = cairo.Matrix(fx,0,0,fy,0,0)</td></tr>
+<tr><td>Rotation to A radians<td>ctx.rotate(A)</td><td>mtrx = cairo.Matrix(C,S,-S,C,0,0)</td></tr>
+<tr><td>Rotation to A radians with center in x,y</td><td>ctx.translate(x,y); ctx.rotate(A); ctx.translate(-x,-y)</td><td>mtrx = cairo.Matrix(C,S,-S,C,x-C*x+S*y,y-S*x-C*y)</td></tr>
+<tr><td>X-skew by A</td><td>--</td><td>mtrx = cairo.Matrix(1,0,T,1,0,0)</td></tr>
+<tr><td>Y-skew by A</td><td>--</td><td>mtrx = cairo.Matrix(1,T,0,1,0,0)</td></tr>
+<tr><td>Flip H/V with center in cx:cy</td><td>--</td><td>mtrx = cairo.Matrix(fx,0,0,fy,cx*(1-fx),cy*(fy-1))</td></tr>
+<tr><td>Flip H/V and rotation with center in cx:cy</td><td>--</td><td>mtrx = cairo.Matrix(fx*C,fx*S,-S*fy,C*fy,C*cx*(1-fx)-S*cy*(fy-1)+cx-C*cx+S*cy,S*cx*(1-fx)+C*cy*(fy-1)+cy-S*cx-C*cy)</td></tr>
+</table>
+(For flips fx/fy = 1 means 'no flip', fx/fy = -1 are used for horizontal/vertical flip).
+
+---
+
+To apply more than one transformation you can multiply matrix. 'Unfortunately' matrix multiplication is slightly different than regular multiplication of numbers. For square matrix with N columns and N rows the rule is 'Rij == sum of Aix to Bxj products, where x = [1,N]'.
+It's easy to figure out that for matrix multiplication *A\*B is not always the same as B\*A*.
+The rule of matrix multiplication is illustrated with a picture here:
+
+[[!img "matrix_multiplication.gif" width="911" height="117" link="no"]]
+
+In a cairo.matrix(1,2,3,4,5,6), 1 is a11, 2 is a21, 3 is a12, 4 is a22, 5 is a13 and 6 is a23.
+a31 and a32 are 0, a33 is 1. 
+
+Cairo provides matrix <a href="http://cairographics.org/manual/cairo-cairo-matrix-t.html#cairo-matrix-multiply">multiplication</a> and some other matrix <a href="http://cairographics.org/manual/cairo-cairo-matrix-t.html">functions</a>.
diff --git a/src/cookbook/matrix_transform/matrix_multiplication.gif b/src/cookbook/matrix_transform/matrix_multiplication.gif
new file mode 100644
index 0000000..066c7ae
Binary files /dev/null and b/src/cookbook/matrix_transform/matrix_multiplication.gif differ
diff --git a/src/cookbook/perl_cairo_module.mdwn b/src/cookbook/perl_cairo_module.mdwn
new file mode 100644
index 0000000..728e361
--- /dev/null
+++ b/src/cookbook/perl_cairo_module.mdwn
@@ -0,0 +1,75 @@
+Back to [[cookbook]]
+
+# Install Cairo CPAN Module
+
+Using CPAN:
+        
+        # cpan Cairo
+
+Using CPANPLUS
+        
+        # cpanp -i Cairo
+
+# Examples
+
+## Draw Lines
+
+        #!/usr/bin/perl
+
+        use strict;
+        use warnings;
+        use Cairo;
+
+        use constant
+        {
+            IMG_WIDTH => 640,
+            IMG_HEIGHT => 480,
+            PADDING => "10 10 10 10"  # top , right , bottom , left
+        };
+
+        die "png backend not supported" unless (Cairo::HAS_PNG_FUNCTIONS);
+
+        my $png = shift || "dashed_rect.png";
+
+        my $surf = Cairo::ImageSurface->create ('argb32', IMG_WIDTH, IMG_HEIGHT);
+        my $cr = Cairo::Context->create ($surf);
+
+        $cr->rectangle (0, 0, IMG_WIDTH, IMG_HEIGHT);
+        $cr->set_source_rgba (1, 1, 1, 0.5);
+        $cr->fill;
+
+
+        my %padding;
+
+        @padding{ qw/top right bottom left/ } = split /\s+/,PADDING;
+        my @point = ( 
+            [ $padding{left}, $padding{top} ] ,
+            [ IMG_WIDTH - $padding{right} , $padding{top} ],
+            [ IMG_WIDTH - $padding{right} , IMG_HEIGHT - $padding{bottom} ],
+            [ $padding{left} , IMG_HEIGHT - $padding{bottom} ] ,
+            [ $padding{left}, $padding{top} ] ,
+        );
+
+
+
+        $cr->save;
+        $cr->set_source_rgba (0, 0, 0, 1 );
+        $cr->set_line_width ( 3 );
+        $cr->set_dash ( 0 , 50.0 , 10.0 , 10.0 , 10.0 );
+
+        for my $i (  0 .. 3 )  {
+                my $p = $point[$i] ;
+                my $next_p = $point[ $i + 1 ];
+                $cr->new_path;
+                $cr->move_to (  @$p );
+                $cr->line_to (  @$next_p );
+                $cr->stroke;
+                
+        }
+
+        $cr->restore;
+
+
+
+        $surf->write_to_png ($png);
+
diff --git a/src/cookbook/pycairo_pango.mdwn b/src/cookbook/pycairo_pango.mdwn
new file mode 100644
index 0000000..754c85c
--- /dev/null
+++ b/src/cookbook/pycairo_pango.mdwn
@@ -0,0 +1,62 @@
+## Rendering fonts with Python
+((c) João S. O. Bueno - jsbueno(at)python.org.br. Code license: CreativeCommons BY 3.0)
+
+Using "helvetica" or "sans" fonts with Cairo only is easy with the
+"toyfont" api provided. However, for serious font work, one gets trapped
+as FreeType engine is not implemented. To the rescue, comes  pango, and pangocairo -
+pango is a library created with the sole purpose of high quality text rendering.
+
+Documentation on using pango along with cairo is scarce, and most examples are in C,
+- and those don't map straight into Python.
+
+My system has all the libraries available - I suppose pangocairo comes along with
+the python-pango bindings.
+
+The snippet bellow can render a sample text in a given font family, 
+that can be specified as a command line parameter. It also prints
+the available font families to stdout.
+
+
+    # -*- coding: utf-8 -*-
+    import cairo
+    import pango
+    import pangocairo
+    import sys
+
+    surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 320, 120)
+    context = cairo.Context(surf)
+
+    #draw a background rectangle:
+    context.rectangle(0,0,320,120)
+    context.set_source_rgb(1, 1, 1)
+    context.fill()
+
+    #get font families:
+
+    font_map = pangocairo.cairo_font_map_get_default()
+    families = font_map.list_families()
+
+    # to see family names:
+    print [f.get_name() for f in   font_map.list_families()]
+
+    #context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
+
+    # Translates context so that desired text upperleft corner is at 0,0
+    context.translate(50,25)
+
+    pangocairo_context = pangocairo.CairoContext(context)
+    pangocairo_context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
+
+    layout = pangocairo_context.create_layout()
+    fontname = sys.argv[1] if len(sys.argv) >= 2 else "Sans"
+    font = pango.FontDescription(fontname + " 25")
+    layout.set_font_description(font)
+
+    layout.set_text(u"Hello World")
+    context.set_source_rgb(0, 0, 0)
+    pangocairo_context.update_layout(layout)
+    pangocairo_context.show_layout(layout)
+
+    with open("cairo_text.png", "wb") as image_file:
+        surf.write_to_png(image_file)
+
diff --git a/src/cookbook/pyrsvg.mdwn b/src/cookbook/pyrsvg.mdwn
new file mode 100644
index 0000000..e9dd1fe
--- /dev/null
+++ b/src/cookbook/pyrsvg.mdwn
@@ -0,0 +1,126 @@
+## How to use librsvg from Python
+
+It finally took me an entire installation of a new O/S and "locate .py | grep rsvg"(*) on my drive to find what I could not find via google : how to open an SVG file and draw it from PyCairo.
+
+I had to upgrade my O/S (to Gnu/Linux Kubuntu 7.10) in order to get the latest Python-gnome2-* packages for, buried in there, is a Python wrapper for librsvg. I don't know why it's not a stand-alone wrapper like PyCairo, but that's the way it is.
+
+The first demo is directly from the example I found on my drive.
+
+(*) You can find this demo in /usr/share/doc/python-gnome2-desktop/examples/rsvg on \*buntu Gutsy 7.10
+
+    #!/usr/bin/env python
+    
+    import sys
+    import cairo
+    import rsvg
+    import gtk
+    
+    
+    BORDER_WIDTH = 10
+    
+    
+    def delete_cb(win, event):
+        gtk.main_quit()
+    
+    
+    def expose_cairo(win, event, svg):
+    
+        x, y, w, h = win.allocation
+        cr = win.window.cairo_create()
+        cr.set_source_color(win.style.fg[win.state])
+        cr.rectangle(BORDER_WIDTH, BORDER_WIDTH,
+                    w - 2*BORDER_WIDTH, h - 2*BORDER_WIDTH)
+        cr.set_line_width(5.0)
+        cr.set_line_join(cairo.LINE_JOIN_ROUND)
+        cr.stroke()
+    
+        if svg != None:
+            matrix = cairo.Matrix(3,0,0,3,0, 0)
+            #cairo.Matrix.rotate( matrix, prop.rot )
+            cr.transform (matrix)
+            svg.render_cairo(cr)
+    
+        return True
+    
+    def main():
+        win = gtk.Window ()
+        win.connect("delete-event", delete_cb)
+    
+        svg = None
+        if (len (sys.argv) > 1):
+            svg = rsvg.Handle(file=sys.argv[1])
+        else:
+            raise SystemExit("need svg file")
+    
+        win.connect("expose-event", expose_cairo, svg)
+    
+        print svg.props.width, svg.props.height, svg.props.em, svg.props.ex
+    
+        win.show_all()
+        win.connect("destroy", lambda w: gtk.main_quit())
+        gtk.main()
+    
+    if __name__ == '__main__':
+        main()
+
+##Writing an SVG file
+
+I thought I'd see how writing **out** an SVG file from Cairo works, this is a short example.
+
+
+    import cairo
+    import rsvg
+    import math
+    
+    fo = file('test.svg', 'w')
+    
+    WIDTH, HEIGHT  = 256, 256
+    
+    ## Prepare a destination surface -> out to an SVG file!
+    surface = cairo.SVGSurface (fo, WIDTH, HEIGHT)
+    
+    ## draw something - this taken from the web.
+    ctx = cairo.Context (surface)
+    ctx.scale (WIDTH/1.0, HEIGHT/1.0) # Normalizing the canvas
+    pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0)
+    pat.add_color_stop_rgba (1, 0.7, 0, 0, 0.5) # First stop, 50% opacity
+    pat.add_color_stop_rgba (0, 0.9, 0.7, 0.2, 1) # Last stop, 100% opacity
+    ctx.rectangle (0, 0, 1, 1) # Rectangle(x0, y0, x1, y1)
+    ctx.set_source (pat)
+    ctx.fill ()
+    ctx.translate (0.1, 0.1) # Changing the current transformation matrix
+    ctx.move_to (0, 0)
+    ctx.arc (0.2, 0.1, 0.1, -math.pi/2, 0) # Arc(cx, cy, radius, start_angle, stop_angle)
+    ctx.line_to (0.5, 0.1) # Line to (x,y)
+    ctx.curve_to (0.5, 0.2, 0.5, 0.4, 0.2, 0.8) # Curve(x1, y1, x2, y2, x3, y3)
+    ctx.close_path ()
+    ctx.set_source_rgb (0.3, 0.2, 0.5) # Solid color
+    ctx.set_line_width (0.02)
+    ctx.stroke ()
+    
+    ## Do the deed.
+    surface.finish()
+
+You can use 'svgdisplay' (if you have the binary), Inkscape, Firefox or the first demo app to view test.svg
+
+##A feedback loop
+
+What happens when you feed the snake its tail?
+
+    import cairo
+    import rsvg
+    
+    fo = file('test.svg', 'w')
+    
+    WIDTH, HEIGHT  = 256, 256
+    surface = cairo.SVGSurface (fo, WIDTH, HEIGHT)
+    
+    ctx = cairo.Context (surface)
+    
+    svg = rsvg.Handle(file="test2.svg")
+    svg.render_cairo(ctx)
+    
+    surface.finish()
+
+Well, it works! test.svg comes in and comes out as test2.svg. I don't think it proves anything, but it's fun.
+
diff --git a/src/cookbook/pythoncairopil.mdwn b/src/cookbook/pythoncairopil.mdwn
new file mode 100644
index 0000000..ffd8a57
--- /dev/null
+++ b/src/cookbook/pythoncairopil.mdwn
@@ -0,0 +1,21 @@
+[[!meta title="PIL and Cairographics / PyCairo"]]
+
+Please note that the code below was to only blur an cairo image surface and thus ignores conversion from BGRA to RGBA to BGRA that is needed in other situations. Theoretically just replace RGBA with BGRA in frombuffer and tostring.
+
+    import cairo, Image, array
+
+    im = cairo.ImageSurface.create_from_png("img11.png")
+            
+    im1 = Image.frombuffer("RGBA",( im.get_width(),im.get_height() ),im.get_data(),"raw","RGBA",0,1)
+            
+    im1 = im1.filter(ImageFilter.BLUR)
+    im1 = im1.filter(ImageFilter.BLUR)
+    im1 = im1.filter(ImageFilter.SMOOTH_MORE) 
+            
+    #imgd = im1.tostring("raw","RGBA",0,1)
+    imgd = im1.tostring()
+    a = array.array('B',imgd)
+            
+    stride = self.width * 4
+    surface = cairo.ImageSurface.create_for_data (a, cairo.FORMAT_ARGB32,
+                                                  self.width, self.height, stride) 
diff --git a/src/cookbook/quickframework.mdwn b/src/cookbook/quickframework.mdwn
new file mode 100644
index 0000000..5718910
--- /dev/null
+++ b/src/cookbook/quickframework.mdwn
@@ -0,0 +1,70 @@
+##A Quick GTK+ GNU/Linux Framework
+
+I got this from <http://www.tortall.net/mu/wiki/PyGTKCairoTutorial> : it's handy for running snippets of cairo code to see what's going on.
+
+This sample shows how to use a mask (a second source to filter the first source.)
+
+
+    #! /usr/bin/env python
+    import pygtk
+    pygtk.require('2.0')
+    import gtk, gobject, cairo
+    
+    # Create a GTK+ widget on which we will draw using Cairo
+    class Screen(gtk.DrawingArea):
+    
+        # Draw in response to an expose-event
+        __gsignals__ = { "expose-event": "override" }
+    
+        # Handle the expose-event by drawing
+        def do_expose_event(self, event):
+    
+            # Create the cairo context
+            cr = self.window.cairo_create()
+    
+            # Restrict Cairo to the exposed area; avoid extra work
+            cr.rectangle(event.area.x, event.area.y,
+                    event.area.width, event.area.height)
+            cr.clip()
+    
+            self.draw(cr, *self.window.get_size())
+    
+        def draw(self, cr, width, height):
+            # Fill the background with gray
+            cr.set_source_rgb(0.5, 0.5, 0.5)
+            cr.rectangle(0, 0, width, height)
+            cr.fill()
+    
+    # GTK mumbo-jumbo to show the widget in a window and quit when it's closed
+    def run(Widget):
+        window = gtk.Window()
+        window.connect("delete-event", gtk.main_quit)
+        widget = Widget()
+        widget.show()
+        window.add(widget)
+        window.present()
+        gtk.main()
+
+
+    
+    ## Do all your testing in Shapes ##
+
+
+    
+    class Shapes(Screen):
+        def draw(self, cr, width, height):
+            
+            ## This will draw using a mask.
+            cr.scale(width,height) #Without this line the mask does not seem to work!
+            self.linear = cairo.LinearGradient(0, 0, 1, 1)
+            self.linear.add_color_stop_rgb(0, 0, 0.3, 0.8)
+            self.linear.add_color_stop_rgb(1, 0, 0.8, 0.3)
+            
+            self.radial = cairo.RadialGradient(0.5, 0.5, 0.25, 0.5, 0.5, 0.5)
+            self.radial.add_color_stop_rgba(0, 0, 0, 0, 1)
+            self.radial.add_color_stop_rgba(0.5, 0, 0, 0, 0)
+            
+            cr.set_source(self.linear)
+            cr.mask(self.radial)       
+    
+    run(Shapes)
diff --git a/src/cookbook/renderpdf.mdwn b/src/cookbook/renderpdf.mdwn
new file mode 100644
index 0000000..790daf9
--- /dev/null
+++ b/src/cookbook/renderpdf.mdwn
@@ -0,0 +1,200 @@
+##Rendering a PDF or PS file with cairo
+
+PDF files can be rendered to a cairo context using poppler. PS or EPS files can also be rendered to a cairo context by first converting to PDF using Ghostscript.
+
+When using a vector backend, the vectors and text in the PDF file are preserved in the output as vectors. There is no unnecessary rasterization.
+
+Compile the examples with:
+
+    gcc -o pdftops pdftops.c `pkg-config --cflags --libs cairo poppler-glib`
+    gcc -o pdftoimage pdftoimage.c `pkg-config --cflags --libs cairo poppler-glib`
+
+pdftops.c - Render a PDF file to a cairo PostScript surface.
+
+    #include <poppler.h>
+    #include <cairo.h>
+    #include <cairo-ps.h>
+
+    int main(int argc, char *argv[])
+    {
+        PopplerDocument *document;
+        PopplerPage *page;
+        double width, height;
+        GError *error;
+        const char *filename;
+        gchar *absolute, *uri;
+        int num_pages, i;
+        cairo_surface_t *surface;
+        cairo_t *cr;
+        cairo_status_t status;
+
+        if (argc != 2) {
+            printf ("Usage: pdf2cairo input_file.pdf\n");
+            return 0;
+        }
+
+        filename = argv[1];
+        g_type_init ();
+        error = NULL;
+
+        if (g_path_is_absolute(filename)) {
+            absolute = g_strdup (filename);
+        } else {
+            gchar *dir = g_get_current_dir ();
+            absolute = g_build_filename (dir, filename, (gchar *) 0);
+            free (dir);
+        }
+
+        uri = g_filename_to_uri (absolute, NULL, &error);
+        free (absolute);
+        if (uri == NULL) {
+            printf("poppler fail: %s\n", error->message);
+            return 1;
+        }
+
+        document = poppler_document_new_from_file (uri, NULL, &error);
+        if (document == NULL) {
+            printf("poppler fail: %s\n", error->message);
+            return 1;
+        }
+
+        num_pages = poppler_document_get_n_pages (document);
+
+        /* Page size does not matter here as the size is changed before
+         * each page */
+        surface = cairo_ps_surface_create ("output.ps", 595, 842);
+        cr = cairo_create (surface);
+        for (i = 0; i < num_pages; i++) {
+            page = poppler_document_get_page (document, i);
+            if (page == NULL) {
+                printf("poppler fail: page not found\n");
+                return 1;
+            }
+            poppler_page_get_size (page, &width, &height);
+            cairo_ps_surface_set_size (surface, width, height);
+            cairo_save (cr);
+            poppler_page_render_for_printing (page, cr);
+            cairo_restore (cr);
+            cairo_surface_show_page (surface);
+            g_object_unref (page);
+        }
+        status = cairo_status(cr);
+        if (status)
+            printf("%s\n", cairo_status_to_string (status));
+        cairo_destroy (cr);
+        cairo_surface_finish (surface);
+        status = cairo_surface_status(surface);
+        if (status)
+            printf("%s\n", cairo_status_to_string (status));
+        cairo_surface_destroy (surface);
+
+        g_object_unref (document);
+
+        return 0;
+    }
+
+
+pdftoimage.c - Render a one page of a PDF file to a cairo image surface.
+
+    #include <stdio.h>
+    #include <stdlib.h>
+    #include <poppler.h>
+    #include <cairo.h>
+
+    #define IMAGE_DPI 150
+
+    int main(int argc, char *argv[])
+    {
+        PopplerDocument *document;
+        PopplerPage *page;
+        double width, height;
+        GError *error;
+        const char *pdf_file;
+        const char *png_file;
+        gchar *absolute, *uri;
+        int page_num, num_pages;
+        cairo_surface_t *surface;
+        cairo_t *cr;
+        cairo_status_t status;
+
+        if (argc != 4) {
+            printf ("Usage: pdftoimage input_file.pdf output_file.png page\n");
+            return 0;
+        }
+
+        pdf_file = argv[1];
+        png_file = argv[2];
+        page_num = atoi(argv[3]);
+        g_type_init ();
+        error = NULL;
+
+        if (g_path_is_absolute(pdf_file)) {
+            absolute = g_strdup (pdf_file);
+        } else {
+            gchar *dir = g_get_current_dir ();
+            absolute = g_build_filename (dir, pdf_file, (gchar *) 0);
+            free (dir);
+        }
+
+        uri = g_filename_to_uri (absolute, NULL, &error);
+        free (absolute);
+        if (uri == NULL) {
+            printf("%s\n", error->message);
+            return 1;
+        }
+
+        document = poppler_document_new_from_file (uri, NULL, &error);
+        if (document == NULL) {
+            printf("%s\n", error->message);
+            return 1;
+        }
+
+        num_pages = poppler_document_get_n_pages (document);
+        if (page_num < 1 || page_num > num_pages) {
+            printf("page must be between 1 and %d\n", num_pages);
+            return 1;
+        }
+
+        page = poppler_document_get_page (document, page_num - 1);
+        if (page == NULL) {
+            printf("poppler fail: page not found\n");
+            return 1;
+        }
+
+        poppler_page_get_size (page, &width, &height);
+
+        /* For correct rendering of PDF, the PDF is first rendered to a
+         * transparent image (all alpha = 0). */
+        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+                                              IMAGE_DPI*width/72.0,
+                                              IMAGE_DPI*height/72.0);
+        cr = cairo_create (surface);
+        cairo_scale (cr, IMAGE_DPI/72.0, IMAGE_DPI/72.0);
+        cairo_save (cr);
+        poppler_page_render (page, cr);
+        cairo_restore (cr);
+        g_object_unref (page);
+
+        /* Then the image is painted on top of a white "page". Instead of
+         * creating a second image, painting it white, then painting the
+         * PDF image over it we can use the CAIRO_OPERATOR_DEST_OVER
+         * operator to achieve the same effect with the one image. */
+        cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
+        cairo_set_source_rgb (cr, 1, 1, 1);
+        cairo_paint (cr);
+    
+        status = cairo_status(cr);
+        if (status)
+            printf("%s\n", cairo_status_to_string (status));
+
+        cairo_destroy (cr);
+        status = cairo_surface_write_to_png (surface, png_file);
+        if (status)
+            printf("%s\n", cairo_status_to_string (status));
+
+        cairo_surface_destroy (surface);
+
+        g_object_unref (document);
+
+        return 0;
+    }
diff --git a/src/cookbook/svgtopycairo.mdwn b/src/cookbook/svgtopycairo.mdwn
new file mode 100644
index 0000000..2b3ac6a
--- /dev/null
+++ b/src/cookbook/svgtopycairo.mdwn
@@ -0,0 +1,152 @@
+##SVG paths can be parsed and turned into a seqence of cairo commands that re-draw them.
+
+This took a while, the pyparsing had me in knots, but now it's short and sweet. A fuller implementation of what can be done in SVG would be really nice. (Hint...)
+
+Make sure you pass it a very simple SVG file (from Inkscape is best) -- one that has had all the shapes reduced to paths. Oh, and keep your canvas 400 by 400 or it may draw clear off the screen. 
+
+**Depends on** 
+
+1. *elementree*: **import** elementree **as** myDearWatson :) It's a great module for slicing through XML.
+2. *pyparsing*: This module is deeply wonderful. I won't pretend to savvy even 1% of it, but it really does the job. They have a great mailing list where I got a lot of help. It let's you parse strings into lists and that is no small feat.
+
+**SVG Path element** 
+
+To briefly explain, inside an svg file (which is just xml) you'll find a tag named 'g' and under that one or more tags named 'path'. Inside path there is an element called 'd'; that's the actual path. It's formed like this: "COMMAND NUMBER COMMA NUMBER Optionally[NUMBER COMMA NUMBER a few more times]", where COMMAND is M for move, L for line, C for curve and Z for close path. There may be others, but that's what I tackled. Have a look at the pyparsing grammar which makes it fairly clear how different commands have different numbers behind them.
+
+Please forgive any bugs.
+
+
+    #!/usr/bin/env python
+    """\
+    Usage: drawsvg.py file
+    file  - one SVG file (from Inkscape!) that is all simple paths
+    
+    """
+    ##    svg2py Copyright  (C)  2007 Donn.C.Ingle
+    ##
+    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
+    ##
+    ##    This program is free software; you can redistribute it and/or modify
+    ##    it under the terms of the GNU General Public License as published by
+    ##    the Free Software Foundation; either version 2 of the License, or
+    ##     ( at your option )  any later version.
+    ##
+    ##    This program is distributed in the hope that it will be useful,
+    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    ##    GNU General Public License for more details.
+    ##
+    ##    You should have received a copy of the GNU General Public License
+    ##    along with this program; if not, write to the Free Software
+    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+    ##
+    
+    import pygtk
+    pygtk.require('2.0')
+    import gtk, gobject, cairo
+    from pyparsing import *
+    import os, sys
+    from elementtree import ElementTree as et
+    
+    # Create a GTK+ widget on which we will draw using Cairo
+    class Screen(gtk.DrawingArea):
+    
+        # Draw in response to an expose-event
+        __gsignals__ = { "expose-event": "override" }
+    
+        # Handle the expose-event by drawing
+        def do_expose_event(self, event):
+    
+            # Create the cairo context
+            cr = self.window.cairo_create()
+    
+            # Restrict Cairo to the exposed area; avoid extra work
+            cr.rectangle(event.area.x, event.area.y,
+                    event.area.width, event.area.height)
+            cr.clip()
+    
+            self.draw(cr, *self.window.get_size())
+    
+        def draw(self, cr, width, height):
+            # Fill the background with gray
+            cr.set_source_rgb(0.5, 0.5, 0.5)
+            cr.rectangle(0, 0, width, height)
+            cr.fill()
+    
+    # GTK mumbo-jumbo to show the widget in a window and quit when it's closed
+    def run(Widget):
+        window = gtk.Window()
+        window.set_size_request(400, 400)
+        window.connect("delete-event", gtk.main_quit)
+        widget = Widget()
+        widget.show()
+        window.add(widget)
+        window.present()
+        gtk.main()
+    
+    ## Do the drawing ##
+    
+    class Shapes(Screen):
+        def draw(self, ctx, width, height):
+            
+            #Build a string of cairo commands
+            cairo_commands = ""
+            command_list = []
+            for tokens in paths:
+                for command,couples in tokens[:-1]: #looks weird, but it works :)
+                    c = couples.asList()
+                    if command == "M":
+                        cairo_commands += "ctx.move_to(%s,%s);" % (c[0],c[1])
+                    if command == "C":
+                        cairo_commands += "ctx.curve_to(%s,%s,%s,%s,%s,%s);" % (c[0],c[1],c[2],c[3],c[4],c[5])
+                    if command == "L":
+                        cairo_commands += "ctx.line_to(%s,%s);" % (c[0],c[1])
+                    if command == "Z":
+                        cairo_commands += "ctx.close_path();"
+        
+                command_list.append(cairo_commands) #Add them to the list
+                cairo_commands = ""
+            #Draw it. Only stroked, to fill as per the SVG drawing is another whole story.
+            ctx.set_source_rgb(1,0,0)    
+            for c in command_list:
+                exec(c)
+            ctx.stroke()
+
+    
+    #Check args:
+    if len(sys.argv) < 2:
+        raise SystemExit(__doc__)
+    file = sys.argv[1]
+    
+    ## Pyparsing grammar:
+    ## With HUGE help from Paul McGuire <paul at alanweberassociates.com>
+    ## Thanks!
+    dot = Literal(".")
+    comma = Literal(",").suppress()
+    floater = Combine(Optional("-") + Word(nums) + dot + Word(nums))
+    ## Unremark to have numbers be floats rather than strings.
+    #floater.setParseAction(lambda toks:float(toks[0]))
+    couple = floater + comma + floater
+    M_command = "M" + Group(couple)
+    C_command = "C" + Group(couple + couple + couple)
+    L_command = "L" + Group(couple)
+    Z_command = "Z"
+    svgcommand = M_command | C_command | L_command | Z_command
+    phrase = OneOrMore(Group(svgcommand)) 
+    
+    ## Find and open the svg file
+    xml_file = os.path.abspath(__file__)
+    xml_file = os.path.dirname(xml_file)
+    xml_file = os.path.join(xml_file, file)
+    
+    tree = et.parse(xml_file)
+    
+    ns = "http://www.w3.org/2000/svg" #The XML namespace.
+    paths = []
+    for group in tree.getiterator('{%s}g' % ns):
+        for e in group.getiterator('{%s}path' % ns):
+            p = e.get("d")
+            tokens = phrase.parseString(p.upper())
+            paths.append(tokens) # paths is a global var.
+    
+    run(Shapes)
diff --git a/src/dotnet-gdi-rendering.mdwn b/src/dotnet-gdi-rendering.mdwn
deleted file mode 100644
index c01a67a..0000000
--- a/src/dotnet-gdi-rendering.mdwn
+++ /dev/null
@@ -1,47 +0,0 @@
-Using GDI+ Bitmap as surface can be as simple as that (given in managed C++):
-
-	// Create the target bitmap to draw to.
-	Drawing::Bitmap contentBitmap= new Drawing::Bitmap(Width, Height);
-
-	// Create a Graphics object to have a device context we can pass to cairo.
-	Graphics^ g = Graphics::FromImage(contentBitmap);
-	g->SmoothingMode = SmoothingMode::HighQuality;
-
-	// Do some drawing in GDI+ to have some initial content, like:
-	// Fill interior.
-	Brush^ brush = gcnew SolidBrush(Color::FromArgb(191, 1, 0, 0));
-	g->FillPath(brush, innerPath);
-	delete brush;
-
-	// Get the device context handle from this graphics object and create a Win32 cairo surface from it.
-	IntPtr hdc= g->GetHdc();
-	cairo_surface_t* surface= cairo_win32_surface_create((HDC) hdc.ToPointer());
-
-	// For drawing we need a cairo context.
-	cairo_t* cr= cairo_create(surface);
-
-	// Now you are ready to draw to that using any of the cairo calls.
-	...
-
-	// Don't forget the cleanup.
-	cairo_destroy(cr);
-	cairo_surface_destroy(surface);
-
-	g->ReleaseHdc(hdc);
-
-This works quite well but has one big disadvantage: `cairo_win32_surface_create()` always returns a 24bit surface. So what if we have a bitmap with an alpha channel (like a png image we loaded and want to add something to it)? With the code above the alpha channel used in your cairo commands is lost.
-
-One could create a 32bit DIB surface (using `cairo_win32_surface_create_with_dib()`), but that creates a **separate** surface, which needs to be merged later to your actual target. Using an API like AlphaBlend (via pinvoke) produces exactly the same result as in the code above. So this is no help either.
-
-The solution for this dilemma is an image surface (e.g. you get an image surface when you load png images in cairo).
-
-	// Instead of getting an HDC and and use cairo_win32_surface we get directly
-	// to the pixels in the bitmap and create the image surface from that.
-	Imaging::BitmapData^ bitmapData= contentBitmap->LockBits(Drawing::Rectangle(0, 0, Width, Height),
-	  Imaging::ImageLockMode::ReadWrite, contentBitmap->PixelFormat);
-	unsigned char* data= (unsigned char*) bitmapData->Scan0.ToPointer();
-	cairo_surface_t* surface= cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, Width, Height,
-	  bitmapData->Stride);
-
-	// The rest is the same as above, except we have to unlock the bits after we finished drawing.
-	contentBitmap->UnlockBits(bitmapData);
diff --git a/src/emboss.mdwn b/src/emboss.mdwn
deleted file mode 100644
index 0face4f..0000000
--- a/src/emboss.mdwn
+++ /dev/null
@@ -1,159 +0,0 @@
-##Emboss a cairo surface
-
-This sample shows how to apply an emboss effect to a cairo A8 image surface.
-
-    /*
-    Adapted from "Fast Embossing Effects on Raster Image Data"
-
-	    Original code by: John Schlag, <jfs at kerner.com>
-	    Adapted code by: Jeremy Moles, <cubicool at gmail.com>
-
-    Found in the publication "Graphics Gems IV", Academic Press, 1994
-    */
-
-    #include <cairo.h>
-    #include <math.h>
-    #include <stdio.h>
-    #include <string.h>
-    #include <stdlib.h>
-
-    #define PIXEL_SCALE 255
-    #define WIDTH_45    1
-
-    /* This function will use an exisiting surface's data and create and NEW surface copy
-    // of that data which has the emboss lighting algorithm applied to it. */
-    static cairo_surface_t* _create_embossed_surface_from_surface(
-	    cairo_surface_t* surface,
-	    double           azimuth,
-	    double           elevation
-    ) {
-	    unsigned char* src    = cairo_image_surface_get_data(surface);
-	    unsigned int   width  = cairo_image_surface_get_width(surface);
-	    unsigned int   stride = cairo_image_surface_get_stride(surface);
-	    unsigned int   height = cairo_image_surface_get_height(surface);
-
-	    cairo_surface_t* dstSurface = cairo_image_surface_create(CAIRO_FORMAT_A8, width, height);
-
-	    unsigned char* dst = cairo_image_surface_get_data(dstSurface);
-
-	    /* Compute the light vector from the input parameters.
-	    // Normalize the length to PIXEL_SCALE for fast shading calculation. */
-	    long Lx   = cos(azimuth) * cos(elevation) * PIXEL_SCALE;
-	    long Ly   = sin(azimuth) * cos(elevation) * PIXEL_SCALE;
-	    long Lz   = sin(elevation) * PIXEL_SCALE;
-	    long Nz   = (6 * 255) / WIDTH_45;
-	    long Nz2  = Nz * Nz;
-	    long NzLz = Nz * Lz;
-
-	    unsigned int y = 1;
-	    unsigned int x = 1;
-
-	    /* TODO: Would it be better to fill DST with SRC instead of the Lz value?
-	    // memcpy(dst, src, stride * height); */
-	    memset(dst, Lz, stride * height);
-
-	    for(y = 1; y < height - 2; y++) {
-		    for(x = 1; x < stride - 1; x++) {
-			    unsigned int   offset = (y * stride) + x;
-			    unsigned char* s1     = src + offset;
-			    unsigned char* s2     = s1 + stride;
-			    unsigned char* s3     = s2 + stride;
-			    unsigned char  shade  = 0;
-
-			    /* Compute the normal from the source. The type of the expression
-			    // before the cast is compiler dependent. In some cases the sum is
-			    // unsigned, in others it is signed. Ergo, cast to signed. */
-			    long Nx = (long)(s1[-1] + s2[-1] + s3[-1] - s1[1] - s2[1] - s3[1]);
-			    long Ny = (long)(s3[-1] + s3[0] + s3[1] - s1[-1] - s1[0] - s1[1]);
-
-			    long NdotL = Nx * Lx + Ny * Ly + NzLz;
-
-			    /* Shade with distant light source. */
-			    if(!Nx && !Ny) shade = Lz;
-
-			    else if(NdotL < 0) shade = 0;
-
-			    else shade = NdotL / sqrt(Nx * Nx + Ny * Ny + Nz2);
-
-			    *(dst + offset) = shade;
-		    }
-	    }
-
-	    return dstSurface;
-    }
-
-    /* This function only supports A8 surfaces at the moment, and delegates work to the
-    // similarly named function above. */
-    static cairo_surface_t* create_embossed_surface_from_surface(
-	    cairo_surface_t* surface,
-	    double           azimuth,
-	    double           elevation
-    ) {
-	    if(cairo_image_surface_get_format(surface) != CAIRO_FORMAT_A8) {
-		    printf("This example only supports embossing A8 surfaces.\n");
-		    printf("It shouldn't be too wildy hard to add other format types.\n");
-
-		    return 0;
-	    }
-
-	    else return _create_embossed_surface_from_surface(surface, azimuth, elevation);
-    }
-
-    int main(int argc, char** argv) {
-	    unsigned int w        = 400;
-	    unsigned int h        = 50;
-	    unsigned int textSize = 35;
-	    const char*  text     = "Cairo Emboss!!!";
-
-	    cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_A8, w, h);
-	    cairo_t*         cr      = cairo_create(surface);
-
-	    cairo_text_extents_t extents;
-
-	    if(argc != 3) {
-		    printf(
-			    "usage: %s <int> <int>\nThe two integral arguments passed in are "
-			    "the light azimuth and elevation values, in angles.\n",
-			    argv[0]
-		    );
-
-		    goto cleanup;
-	    }
-
-	    cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
-	    cairo_set_font_size(cr, textSize);
-	    cairo_text_extents(cr, text, &extents);
-
-	    cairo_move_to(
-		    cr,
-		    ((double)(w - extents.width) / 2.0f) - extents.x_bearing,
-		    (double)(h - extents.y_bearing) / 2.0f
-	    );
-
-	    cairo_show_text(cr, text);
-
-	    cairo_surface_t* emboss = create_embossed_surface_from_surface(
-		    surface, 
-		    atoi(argv[1]) * (M_PI / 180.0f),
-		    atoi(argv[2]) * (M_PI / 180.0f)
-	    );
-
-	    if(!emboss) {
-		    printf("Calling the emboss function failed; cleaning up and leaving.\n");
-
-		    goto cleanup;
-	    }
-
-	    cairo_surface_write_to_png(surface, "cairo_emboss_normal.png");
-	    cairo_surface_write_to_png(emboss, "cairo_emboss_embossed.png");
-
-	    printf("Wrote cairo_emboss_{normal,embossed}.png to your local directory.\n");
-
-	    cairo_surface_destroy(emboss);
-
-    cleanup:
-	    cairo_surface_destroy(surface);
-	    cairo_destroy(cr);
-
-	    return 0;
-    }
diff --git a/src/freetypepython.mdwn b/src/freetypepython.mdwn
deleted file mode 100644
index a1a48de..0000000
--- a/src/freetypepython.mdwn
+++ /dev/null
@@ -1,89 +0,0 @@
-[[!meta title="Loading fonts using FreeType for cairo use in Python"]]
-Back to [[cookbook]]
-
-The following snippet uses Python's ctypes module to load a font file using FreeType
-and create a cairo font face from it, using the cairo-ft API that is not part of pycairo yet.
-The resulting cairo font face however can be used normally with pycairo.
-
-
-	import ctypes
-	import cairo
-
-
-	_initialized = False
-	def create_cairo_font_face_for_file (filename, faceindex=0, loadoptions=0):
-		global _initialized
-		global _freetype_so
-		global _cairo_so
-		global _ft_lib
-		global _surface
-
-		CAIRO_STATUS_SUCCESS = 0
-		FT_Err_Ok = 0
-
-		if not _initialized:
-
-			# find shared objects
-			_freetype_so = ctypes.CDLL ("libfreetype.so.6")
-			_cairo_so = ctypes.CDLL ("libcairo.so.2")
-
-			_cairo_so.cairo_ft_font_face_create_for_ft_face.restype = ctypes.c_void_p
-			_cairo_so.cairo_ft_font_face_create_for_ft_face.argtypes = [ ctypes.c_void_p, ctypes.c_int ]
-			_cairo_so.cairo_set_font_face.argtypes = [ ctypes.c_void_p, ctypes.c_void_p ]
-			_cairo_so.cairo_font_face_status.argtypes = [ ctypes.c_void_p ]
-			_cairo_so.cairo_status.argtypes = [ ctypes.c_void_p ]
-
-			# initialize freetype
-			_ft_lib = ctypes.c_void_p ()
-			if FT_Err_Ok != _freetype_so.FT_Init_FreeType (ctypes.byref (_ft_lib)):
-			  raise "Error initialising FreeType library."
-
-			class PycairoContext(ctypes.Structure):
-			    _fields_ = [("PyObject_HEAD", ctypes.c_byte * object.__basicsize__),
-					("ctx", ctypes.c_void_p),
-					("base", ctypes.c_void_p)]
-
-			_surface = cairo.ImageSurface (cairo.FORMAT_A8, 0, 0)
-
-			_initialized = True
-
-		# create freetype face
-		ft_face = ctypes.c_void_p()
-		cairo_ctx = cairo.Context (_surface)
-		cairo_t = PycairoContext.from_address(id(cairo_ctx)).ctx
-
-		if FT_Err_Ok != _freetype_so.FT_New_Face (_ft_lib, filename, faceindex, ctypes.byref(ft_face)):
-			raise Exception("Error creating FreeType font face for " + filename)
-
-		# create cairo font face for freetype face
-		cr_face = _cairo_so.cairo_ft_font_face_create_for_ft_face (ft_face, loadoptions)
-		if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_font_face_status (cr_face):
-			raise Exception("Error creating cairo font face for " + filename)
-
-		_cairo_so.cairo_set_font_face (cairo_t, cr_face)
-		if CAIRO_STATUS_SUCCESS != _cairo_so.cairo_status (cairo_t):
-			raise Exception("Error creating cairo font face for " + filename)
-
-		face = cairo_ctx.get_font_face ()
-
-		return face
-
-	if __name__ == '__main__':
-
-		face = create_cairo_font_face_for_file ("/usr/share/fonts/dejavu-lgc/DejaVuLGCSerif.ttf", 0)
-
-		surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 128, 128)
-
-		ctx = cairo.Context(surface)
-
-		ctx.set_font_face(face)
-		ctx.set_font_size(30)
-		ctx.move_to(0, 44)
-		ctx.show_text("Hello,")
-
-		ctx.move_to(30, 74)
-		ctx.show_text("world!")
-
-		del ctx
-
-		surface.write_to_png("hello.png")
diff --git a/src/gdkpixbufpycairo.mdwn b/src/gdkpixbufpycairo.mdwn
deleted file mode 100644
index 1eacc7f..0000000
--- a/src/gdkpixbufpycairo.mdwn
+++ /dev/null
@@ -1,40 +0,0 @@
-[[!meta title="Loading images"]]
-Back to [[cookbook]]
-
-Based on the cworth recipe.
-Loads file in any gdk-pixbuf supported format (look into your gdk-pixbuf.loaders or run 'gdk-pixbuf-query-loaders | grep gtk20').
-Can be used as a very primitive image viewer.
-
-    #!/usr/bin/env python
-    import sys
-    import gtk
-    import cairo
-
-    def expose (da, event, pixbuf):
-      ctx = da.window.cairo_create()
-      # You can put ctx.scale(..) or ctx.rotate(..) here, if you need some
-      ctx.set_source_pixbuf(pixbuf,0,0)
-      ctx.paint()
-      ctx.stroke()
-
-    def main():
-      filename = sys.argv[1]
-      pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
-      imgw=pixbuf.get_width()
-      imgh=pixbuf.get_height()
-      win = gtk.Window()
-      win.connect('destroy', gtk.main_quit)
-      win.set_default_size(imgw, imgh)
-      da = gtk.DrawingArea()
-      win.add(da)
-      da.connect('expose_event', expose, pixbuf)
-      win.show_all()
-      gtk.main()
-
-    if __name__ == '__main__':
-      if len(sys.argv) != 2:
-        program = sys.argv[0]
-        print program +':', 'usage:', program, '<filename>'
-        sys.exit(0)
-      else:
-        main()
\ No newline at end of file
diff --git a/src/hittestpython.mdwn b/src/hittestpython.mdwn
deleted file mode 100644
index 6ea465f..0000000
--- a/src/hittestpython.mdwn
+++ /dev/null
@@ -1,200 +0,0 @@
-## A quick recipe for testing a hit on an area.
-
-Once you've drawn something and **before** you cr.fill() or cr.stroke(), you can record the path to a list of points for later use. This recipe includes an algorithm to tell whether a point is within that path's area or not. It prints to the console, so it's not exactly bling, but it's pretty nifty for all that. Go see <http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/> for the theory behind the voodoo :)
-
-##Newsflash
-
-Jeff Muizelaar informed me that Cairo has a built-in function to do this anyway. See code listing 2.
-
-    #! /usr/bin/env python
-
-    ##    hittest Copyright  (C)  2007 Donn.C.Ingle
-    ##
-    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
-    ##
-    ##    This program is free software; you can redistribute it and/or modify
-    ##    it under the terms of the GNU General Public License as published by
-    ##    the Free Software Foundation; either version 2 of the License, or
-    ##     ( at your option )  any later version.
-    ##
-    ##    This program is distributed in the hope that it will be useful,
-    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    ##    GNU General Public License for more details.
-    ##
-    ##    You should have received a copy of the GNU General Public License
-    ##    along with this program; if not, write to the Free Software
-    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-    ##
-
-    import pygtk
-    pygtk.require('2.0')
-    import gtk, gobject, cairo
-    from gtk import gdk
-    
-    # Create a GTK+ widget on which we will draw using Cairo
-    class Screen(gtk.DrawingArea):
-    
-        # Draw in response to an expose-event
-        __gsignals__ = { "expose-event": "override" }
-    
-        def __init__(self):
-            super(Screen,self).__init__()
-            # gtk.Widget signals
-            self.connect("button_press_event", self.button_press)
-            self.connect("button_release_event", self.button_release)
-            self.connect("motion_notify_event", self.motion_notify)
-            # More GTK voodoo : unmask events
-            self.add_events(gdk.BUTTON_PRESS_MASK |
-                            gdk.BUTTON_RELEASE_MASK |
-                            gdk.POINTER_MOTION_MASK)
-            
-        # Handle the expose-event by drawing
-        def do_expose_event(self, event):
-    
-            # Create the cairo context
-            cr = self.window.cairo_create()
-            self.hitpath = None #Is set later
-            
-            # Restrict Cairo to the exposed area; avoid extra work
-            cr.rectangle(event.area.x, event.area.y,
-                    event.area.width, event.area.height)
-            cr.clip()
-    
-            self.draw(cr, *self.window.get_size())
-            
-        def makeHitPath(self,cairopath):
-            ## Make a simpler list of tuples
-            
-            ##        Internally, a cairo path looks like this:
-            ##        (0, (10.0, 10.0))
-            ##        (1, (60.0, 10.0))
-            ##        (1, (60.0, 60.0))
-            ##        (1, (35.0, 60.0))
-            ##        (1, (35.0, 35.0))
-            ##        (1, (10.0, 35.0))
-            ##        (1, (10.0, 60.0))
-            ##        (1, (-40.0, 60.0))
-            ##        (3, ()) #want to ignore this one
-            ##        (0, (10.0, 10.0))        
-            
-            self.hitpath = []
-            for sub in cairopath:
-                if sub[1]: #kick out the close path () empty tuple
-                    self.hitpath.append(sub[1]) #list of tuples
-            
-        def draw(self, cr, width, height):
-            # Fill the background with gray
-            cr.set_source_rgb(0.5, 0.5, 0.5)
-            cr.rectangle(0, 0, width, height)
-            cr.fill()
-            
-        def hitTest(self,*p):
-            ## Code lifted from http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/
-            ## converted to Python. I won't pretend I grok it at all, just glad it works!
-            ## Not sure how well it works yet, it might have edge flaws.
-            px = p[0]
-            py = p[1]
-            counter = i = xinters = 0
-            p1 = p2 = ()
-                
-            p1 = self.hitpath[0]
-            N = len(self.hitpath)
-            
-            # Mathemagic loop-de-loop
-            for i in range(0,N):
-                p2 = self.hitpath[i % N]
-                if py > min( p1[1] , p2[1] ):
-                    if py <= max( p1[1], p2[1] ):
-                        if px <= max( p1[0], p2[0] ):
-                            if p1[1] != p2[1]:
-                                xinters = ( py - p1[1] ) * ( p2[0] - p1[0] ) / ( p2[1] - p1[1] ) + p1[0]
-                                if p1[0] == p2[0] or px <= xinters: counter += 1
-                p1 = p2
-    
-            if counter % 2 == 0:
-                return "outside"
-            return "inside"
-            
-        def button_press(self,widget,event):
-            pass
-        def button_release(self,widget,event):
-            pass
-        def motion_notify(self,widget,event):
-            pass
-    
-    # GTK mumbo-jumbo to show the widget in a window and quit when it's closed
-    def run(Widget):
-        window = gtk.Window()
-        window.connect("delete-event", gtk.main_quit)
-        widget = Widget()
-        widget.show()
-        window.add(widget)
-        window.present()
-        gtk.main()
-    
-    class Shapes(Screen):
-        #Override the press event
-        def button_press(self,widget,event):
-            print self.hitTest(event.x, event.y)
-            
-        def draw(self, cr, width, height):
-            x = y = 10
-            sx = sy = 50
-            cr.move_to(x,y)
-            cr.line_to(x+sx,y)
-            cr.line_to(x+sx,y+sy)
-            cr.line_to(x+(sx/2),y+sy)
-            cr.line_to(x+(sx/2),y+(sy/2))
-            cr.line_to(x,y+(sy/2))
-            cr.line_to(x,y+sy)
-            cr.line_to(x-sx,y+sy)
-            cr.close_path()
-            cr.set_source_rgb(1,0,0)
-            
-            self.makeHitPath(cr.copy_path_flat()) #record the path to use as a hit area.
-            
-            cr.fill() #consumes the path, so get it before the fill
-            
-    
-    run(Shapes)
-
-##Code Listing 2 : It's already done.
-
-    ...snip
-
-    class Shapes(Screen):
-        
-        #Override the press event
-        def button_press(self,widget,event):
-
-            ## Gues what? Cairo had it built-in all along :)
-            ## You just need to keep a ref to the context.
-            ## I'm not sure if re-"drawing" the entire path, just so you can
-            ## test it for a hit is faster than the other version of this
-            ## script that uses a manual python-speed algorithm.
-
-            self.cr.append_path(self.hitpath) # re-gen the path
-            result = self.cr.in_fill(event.x, event.y) # Test it. Sweet.
-            print result
-            
-        def draw(self, cr, width, height):
-            x = y = 10
-            sx = sy = 50
-            cr.move_to(x,y)
-            cr.line_to(x+sx,y)
-            cr.line_to(x+sx,y+sy)
-            cr.line_to(x+(sx/2),y+sy)
-            cr.line_to(x+(sx/2),y+(sy/2))
-            cr.line_to(x,y+(sy/2))
-            cr.line_to(x,y+sy)
-            cr.line_to(x-sx,y+sy)
-            cr.close_path()
-            cr.set_source_rgb(1,0,0)
-            
-            self.hitpath = cr.copy_path_flat() #record the path to use as a hit area.
-            
-            cr.fill() #consumes the path, so get it before the fill
-            
-    
-    run(Shapes)
diff --git a/src/matrix_conventions.mdwn b/src/matrix_conventions.mdwn
deleted file mode 100644
index 938d695..0000000
--- a/src/matrix_conventions.mdwn
+++ /dev/null
@@ -1,86 +0,0 @@
-Matrix transformations are very powerful and useful in computer graphics. But they can be tricky to get right. This article won’t talk about the detailed mathematics of matrices—you can find plenty of descriptions of that elsewhere—but about the practicalities of getting matrix transformations correct in your program code.
-
-First of all, let me offer two important rules when writing matrix-manipulation code:
-
-* **Rule 1: Pick a convention and stick to it.** There are two *self-consistent* ways to write down a matrix transformation that takes a vector in object space (the coordinates in which the object is defined) and transforms it to world space (the coordinates in which the object is viewed): either as *post*-multiplication on a *row* vector, *e.g.*:
-
-       object-space vector → matrix1 → matrix2 → world-space vector
-
-   or as *pre*-multiplication on a *column* vector, *e.g.*:
-
-       world-space vector ← matrix2 ← matrix1 ← object-space vector
-
-   It may look like the first form is more natural (the transformation sequence going left-to-right rather than right-to-left), but in fact most code uses the latter, and it is probably the more convenient form for trying to envision what is going on, as we will see shortly. But the most vital thing is to be *absolutely clear which convention is in effect*.
-
-* **Rule 2: Understand, don’t fiddle.** If your transformations are coming out wrong, *don’t try randomly fiddling with the order of the components to get them right*. You might succeed eventually, but it is quite possible that you made *two* mistakes somewhere that just happen to cancel out. While two wrongs may make a right in this case, you have set a trap for yourself if you (or someone else) have to make an adjustment later: you might try to change the angle of a rotation, for example, only to discover that it has the opposite effect from what you expected; or your *x*-and *y*-scaling might be the wrong way round. So always *try to understand why your transformations are in the order they are*. The effort spent up-front will help keep things less confusing later on.
-
-Now let me give a handy tip for trying to envision the effect of a sequence of matrix transformations. Assuming the usual pre-multiplication-of-column-vectors convention, we can imagine each matrix as a magic box that, when we look through it, transforms the appearance of space on the other side, making things bigger or smaller, rotating or repositioning them and so on. So if we represent object space by the object we are looking at (here a simple line-drawing of a teapot), ahd world space by the eye of the observer, then a transformation like
-
-    world-space vector ← matrix ← object-space vector
-
-can be visualized as
-
-<div align="center">
-[[!img "figure_1.png" link="no"]]
-</div>
-
-where the purple arrows show the flow of geometric information from object space (coordinate system (*x<sub>o</sub>*, *y<sub>o</sub>*)), through the matrix transformation box, to the observer’s eye (coordinate system (*x<sub>w</sub>*, *y<sub>w</sub>*)).
-
-The basic principles apply equally to both 2D and 3D graphics. Here we are dealing with 2D graphics in Cairo. The examples will be in Python, using the high-level [[Qahirah|https://github.com/ldo/qahirah]] binding. This lets us represent the transformation of a <tt>Vector</tt> object by a <tt>Matrix</tt> object directly as a simple Python expression:
-
-    user_space_coord = matrix * object_space_coord
-
-Let us envision what happens if we apply a simple rotational transform to the object.
-
-<div align="center">
-[[!img "figure_2.png" link="no"]]
-</div>
-
-By superimposing both coordinate systems in the upper part of the diagram (the current one in black, the previous one in grey), we can see the differing effects of, for example, moving parallel to the axes in object space coordinates (*x<sub>o</sub>*, *y<sub>o</sub>*) versus world space coordinates (*x<sub>w</sub>*, *y<sub>w</sub>*). In the Python code, we can spread things out across multiple lines, to more closely approximate the arrangement in the diagram:
-
-    user_space_coord = \
-        (
-            Matrix.rotate(45 * deg)
-        *
-            object_space_coord
-        )
-
-Now, what happens if we apply two transformations in succession?
-
-<div align="center">
-[[!img "figure_3.png" link="no"]]
-</div>
-
-Here the transformations (in order from object space to world space) are rotation about the origin, followed by translation along the positive *y*-axis. The rotation converts from object coordinates (*x<sub>o</sub>*, *y<sub>o</sub>*) to the intermediate coordinate system (*x<sub>m</sub>*, *y<sub>m</sub>*). The translation then converts from (*x<sub>m</sub>*, *y<sub>m</sub>*) to (*x<sub>w</sub>*, *y<sub>w</sub>*) coordinates. The equivalent Python code would be something like
-
-    user_space_coord = \
-        (
-            Matrix.translate((0, 10))
-        *
-            Matrix.rotate(45 * deg)
-        *
-            object_space_coord
-        )
-
-Here the order is reversed, the *y*-axis translation being applied first:
-
-<div align="center">
-[[!img "figure_4.png" link="no"]]
-</div>
-
-Thus, the rotation takes place, not about the (*x<sub>o</sub>*, *y<sub>o</sub>*) origin, but about the (*x<sub>m</sub>*, *y<sub>m</sub>*) origin.
-
-**Each transformation (blue background) is applied in the coordinate system of the picture of the object immediately below it (yellow background).**
-
-Note that, while the *orientation* of the teapot ends up the same in both these cases, its *position* is different. The equivalent Python code would be correspondingly rearranged to match the diagram:
-
-    user_space_coord = \
-        (
-            Matrix.rotate(45 * deg)
-        *
-            Matrix.translate((0, 10))
-        *
-            object_space_coord
-        )
-
-So, when you look at the Python code, imagine the eye of the observer on the receiving end of the value of the expression, at the top, while the object coordinates are at the bottom, being processed through successive stages of the transformation until they get to the top. Each individual  <tt>Matrix</tt> object corresponds to one of the boxes with a blue background, while the multiplication asterisk immediately below it corresponds to the picture with the yellow background immediately below that box.
diff --git a/src/matrix_conventions/figure_1.png b/src/matrix_conventions/figure_1.png
deleted file mode 100644
index 28c32ec..0000000
Binary files a/src/matrix_conventions/figure_1.png and /dev/null differ
diff --git a/src/matrix_conventions/figure_2.png b/src/matrix_conventions/figure_2.png
deleted file mode 100644
index 2ce3ca8..0000000
Binary files a/src/matrix_conventions/figure_2.png and /dev/null differ
diff --git a/src/matrix_conventions/figure_3.png b/src/matrix_conventions/figure_3.png
deleted file mode 100644
index 1177705..0000000
Binary files a/src/matrix_conventions/figure_3.png and /dev/null differ
diff --git a/src/matrix_conventions/figure_4.png b/src/matrix_conventions/figure_4.png
deleted file mode 100644
index 7d108da..0000000
Binary files a/src/matrix_conventions/figure_4.png and /dev/null differ
diff --git a/src/matrix_transform.mdwn b/src/matrix_transform.mdwn
deleted file mode 100644
index 93acde1..0000000
--- a/src/matrix_transform.mdwn
+++ /dev/null
@@ -1,33 +0,0 @@
-This is some basic information about matrix transformation for people who forgot their math course or didn't have one.
-
----
-
-Lets take that C = math.cos(A), S = math.sin(A), T = math.tan(A)
-
-mtrx have to be used in the command ctx.transform(mtrx)
-
-<table cellpadding="3" cellspacing="0" border="1" align="center">
-<tr align="center"><td>Action</td><td>Command</td><td>Matrix for transform</td></tr>
-<tr><td>Shift by dx,dy</td><td>ctx.translate(dx,dy)</td><td>mtrx = cairo.Matrix(1,0,0,1,dx,dy)</td></tr>
-<tr><td>Scale by fx,fy</td><td>ctx.scale(fx,fy)</td><td>mtrx = cairo.Matrix(fx,0,0,fy,0,0)</td></tr>
-<tr><td>Rotation to A radians<td>ctx.rotate(A)</td><td>mtrx = cairo.Matrix(C,S,-S,C,0,0)</td></tr>
-<tr><td>Rotation to A radians with center in x,y</td><td>ctx.translate(x,y); ctx.rotate(A); ctx.translate(-x,-y)</td><td>mtrx = cairo.Matrix(C,S,-S,C,x-C*x+S*y,y-S*x-C*y)</td></tr>
-<tr><td>X-skew by A</td><td>--</td><td>mtrx = cairo.Matrix(1,0,T,1,0,0)</td></tr>
-<tr><td>Y-skew by A</td><td>--</td><td>mtrx = cairo.Matrix(1,T,0,1,0,0)</td></tr>
-<tr><td>Flip H/V with center in cx:cy</td><td>--</td><td>mtrx = cairo.Matrix(fx,0,0,fy,cx*(1-fx),cy*(fy-1))</td></tr>
-<tr><td>Flip H/V and rotation with center in cx:cy</td><td>--</td><td>mtrx = cairo.Matrix(fx*C,fx*S,-S*fy,C*fy,C*cx*(1-fx)-S*cy*(fy-1)+cx-C*cx+S*cy,S*cx*(1-fx)+C*cy*(fy-1)+cy-S*cx-C*cy)</td></tr>
-</table>
-(For flips fx/fy = 1 means 'no flip', fx/fy = -1 are used for horizontal/vertical flip).
-
----
-
-To apply more than one transformation you can multiply matrix. 'Unfortunately' matrix multiplication is slightly different than regular multiplication of numbers. For square matrix with N columns and N rows the rule is 'Rij == sum of Aix to Bxj products, where x = [1,N]'.
-It's easy to figure out that for matrix multiplication *A\*B is not always the same as B\*A*.
-The rule of matrix multiplication is illustrated with a picture here:
-
-[[!img "matrix_multiplication.gif" width="911" height="117" link="no"]]
-
-In a cairo.matrix(1,2,3,4,5,6), 1 is a11, 2 is a21, 3 is a12, 4 is a22, 5 is a13 and 6 is a23.
-a31 and a32 are 0, a33 is 1. 
-
-Cairo provides matrix <a href="http://cairographics.org/manual/cairo-cairo-matrix-t.html#cairo-matrix-multiply">multiplication</a> and some other matrix <a href="http://cairographics.org/manual/cairo-cairo-matrix-t.html">functions</a>.
diff --git a/src/matrix_transform/matrix_multiplication.gif b/src/matrix_transform/matrix_multiplication.gif
deleted file mode 100644
index 066c7ae..0000000
Binary files a/src/matrix_transform/matrix_multiplication.gif and /dev/null differ
diff --git a/src/perl_cairo_module.mdwn b/src/perl_cairo_module.mdwn
deleted file mode 100644
index 728e361..0000000
--- a/src/perl_cairo_module.mdwn
+++ /dev/null
@@ -1,75 +0,0 @@
-Back to [[cookbook]]
-
-# Install Cairo CPAN Module
-
-Using CPAN:
-        
-        # cpan Cairo
-
-Using CPANPLUS
-        
-        # cpanp -i Cairo
-
-# Examples
-
-## Draw Lines
-
-        #!/usr/bin/perl
-
-        use strict;
-        use warnings;
-        use Cairo;
-
-        use constant
-        {
-            IMG_WIDTH => 640,
-            IMG_HEIGHT => 480,
-            PADDING => "10 10 10 10"  # top , right , bottom , left
-        };
-
-        die "png backend not supported" unless (Cairo::HAS_PNG_FUNCTIONS);
-
-        my $png = shift || "dashed_rect.png";
-
-        my $surf = Cairo::ImageSurface->create ('argb32', IMG_WIDTH, IMG_HEIGHT);
-        my $cr = Cairo::Context->create ($surf);
-
-        $cr->rectangle (0, 0, IMG_WIDTH, IMG_HEIGHT);
-        $cr->set_source_rgba (1, 1, 1, 0.5);
-        $cr->fill;
-
-
-        my %padding;
-
-        @padding{ qw/top right bottom left/ } = split /\s+/,PADDING;
-        my @point = ( 
-            [ $padding{left}, $padding{top} ] ,
-            [ IMG_WIDTH - $padding{right} , $padding{top} ],
-            [ IMG_WIDTH - $padding{right} , IMG_HEIGHT - $padding{bottom} ],
-            [ $padding{left} , IMG_HEIGHT - $padding{bottom} ] ,
-            [ $padding{left}, $padding{top} ] ,
-        );
-
-
-
-        $cr->save;
-        $cr->set_source_rgba (0, 0, 0, 1 );
-        $cr->set_line_width ( 3 );
-        $cr->set_dash ( 0 , 50.0 , 10.0 , 10.0 , 10.0 );
-
-        for my $i (  0 .. 3 )  {
-                my $p = $point[$i] ;
-                my $next_p = $point[ $i + 1 ];
-                $cr->new_path;
-                $cr->move_to (  @$p );
-                $cr->line_to (  @$next_p );
-                $cr->stroke;
-                
-        }
-
-        $cr->restore;
-
-
-
-        $surf->write_to_png ($png);
-
diff --git a/src/pycairo_pango.mdwn b/src/pycairo_pango.mdwn
deleted file mode 100644
index 754c85c..0000000
--- a/src/pycairo_pango.mdwn
+++ /dev/null
@@ -1,62 +0,0 @@
-## Rendering fonts with Python
-((c) João S. O. Bueno - jsbueno(at)python.org.br. Code license: CreativeCommons BY 3.0)
-
-Using "helvetica" or "sans" fonts with Cairo only is easy with the
-"toyfont" api provided. However, for serious font work, one gets trapped
-as FreeType engine is not implemented. To the rescue, comes  pango, and pangocairo -
-pango is a library created with the sole purpose of high quality text rendering.
-
-Documentation on using pango along with cairo is scarce, and most examples are in C,
-- and those don't map straight into Python.
-
-My system has all the libraries available - I suppose pangocairo comes along with
-the python-pango bindings.
-
-The snippet bellow can render a sample text in a given font family, 
-that can be specified as a command line parameter. It also prints
-the available font families to stdout.
-
-
-    # -*- coding: utf-8 -*-
-    import cairo
-    import pango
-    import pangocairo
-    import sys
-
-    surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, 320, 120)
-    context = cairo.Context(surf)
-
-    #draw a background rectangle:
-    context.rectangle(0,0,320,120)
-    context.set_source_rgb(1, 1, 1)
-    context.fill()
-
-    #get font families:
-
-    font_map = pangocairo.cairo_font_map_get_default()
-    families = font_map.list_families()
-
-    # to see family names:
-    print [f.get_name() for f in   font_map.list_families()]
-
-    #context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
-
-    # Translates context so that desired text upperleft corner is at 0,0
-    context.translate(50,25)
-
-    pangocairo_context = pangocairo.CairoContext(context)
-    pangocairo_context.set_antialias(cairo.ANTIALIAS_SUBPIXEL)
-
-    layout = pangocairo_context.create_layout()
-    fontname = sys.argv[1] if len(sys.argv) >= 2 else "Sans"
-    font = pango.FontDescription(fontname + " 25")
-    layout.set_font_description(font)
-
-    layout.set_text(u"Hello World")
-    context.set_source_rgb(0, 0, 0)
-    pangocairo_context.update_layout(layout)
-    pangocairo_context.show_layout(layout)
-
-    with open("cairo_text.png", "wb") as image_file:
-        surf.write_to_png(image_file)
-
diff --git a/src/pyrsvg.mdwn b/src/pyrsvg.mdwn
deleted file mode 100644
index e9dd1fe..0000000
--- a/src/pyrsvg.mdwn
+++ /dev/null
@@ -1,126 +0,0 @@
-## How to use librsvg from Python
-
-It finally took me an entire installation of a new O/S and "locate .py | grep rsvg"(*) on my drive to find what I could not find via google : how to open an SVG file and draw it from PyCairo.
-
-I had to upgrade my O/S (to Gnu/Linux Kubuntu 7.10) in order to get the latest Python-gnome2-* packages for, buried in there, is a Python wrapper for librsvg. I don't know why it's not a stand-alone wrapper like PyCairo, but that's the way it is.
-
-The first demo is directly from the example I found on my drive.
-
-(*) You can find this demo in /usr/share/doc/python-gnome2-desktop/examples/rsvg on \*buntu Gutsy 7.10
-
-    #!/usr/bin/env python
-    
-    import sys
-    import cairo
-    import rsvg
-    import gtk
-    
-    
-    BORDER_WIDTH = 10
-    
-    
-    def delete_cb(win, event):
-        gtk.main_quit()
-    
-    
-    def expose_cairo(win, event, svg):
-    
-        x, y, w, h = win.allocation
-        cr = win.window.cairo_create()
-        cr.set_source_color(win.style.fg[win.state])
-        cr.rectangle(BORDER_WIDTH, BORDER_WIDTH,
-                    w - 2*BORDER_WIDTH, h - 2*BORDER_WIDTH)
-        cr.set_line_width(5.0)
-        cr.set_line_join(cairo.LINE_JOIN_ROUND)
-        cr.stroke()
-    
-        if svg != None:
-            matrix = cairo.Matrix(3,0,0,3,0, 0)
-            #cairo.Matrix.rotate( matrix, prop.rot )
-            cr.transform (matrix)
-            svg.render_cairo(cr)
-    
-        return True
-    
-    def main():
-        win = gtk.Window ()
-        win.connect("delete-event", delete_cb)
-    
-        svg = None
-        if (len (sys.argv) > 1):
-            svg = rsvg.Handle(file=sys.argv[1])
-        else:
-            raise SystemExit("need svg file")
-    
-        win.connect("expose-event", expose_cairo, svg)
-    
-        print svg.props.width, svg.props.height, svg.props.em, svg.props.ex
-    
-        win.show_all()
-        win.connect("destroy", lambda w: gtk.main_quit())
-        gtk.main()
-    
-    if __name__ == '__main__':
-        main()
-
-##Writing an SVG file
-
-I thought I'd see how writing **out** an SVG file from Cairo works, this is a short example.
-
-
-    import cairo
-    import rsvg
-    import math
-    
-    fo = file('test.svg', 'w')
-    
-    WIDTH, HEIGHT  = 256, 256
-    
-    ## Prepare a destination surface -> out to an SVG file!
-    surface = cairo.SVGSurface (fo, WIDTH, HEIGHT)
-    
-    ## draw something - this taken from the web.
-    ctx = cairo.Context (surface)
-    ctx.scale (WIDTH/1.0, HEIGHT/1.0) # Normalizing the canvas
-    pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0)
-    pat.add_color_stop_rgba (1, 0.7, 0, 0, 0.5) # First stop, 50% opacity
-    pat.add_color_stop_rgba (0, 0.9, 0.7, 0.2, 1) # Last stop, 100% opacity
-    ctx.rectangle (0, 0, 1, 1) # Rectangle(x0, y0, x1, y1)
-    ctx.set_source (pat)
-    ctx.fill ()
-    ctx.translate (0.1, 0.1) # Changing the current transformation matrix
-    ctx.move_to (0, 0)
-    ctx.arc (0.2, 0.1, 0.1, -math.pi/2, 0) # Arc(cx, cy, radius, start_angle, stop_angle)
-    ctx.line_to (0.5, 0.1) # Line to (x,y)
-    ctx.curve_to (0.5, 0.2, 0.5, 0.4, 0.2, 0.8) # Curve(x1, y1, x2, y2, x3, y3)
-    ctx.close_path ()
-    ctx.set_source_rgb (0.3, 0.2, 0.5) # Solid color
-    ctx.set_line_width (0.02)
-    ctx.stroke ()
-    
-    ## Do the deed.
-    surface.finish()
-
-You can use 'svgdisplay' (if you have the binary), Inkscape, Firefox or the first demo app to view test.svg
-
-##A feedback loop
-
-What happens when you feed the snake its tail?
-
-    import cairo
-    import rsvg
-    
-    fo = file('test.svg', 'w')
-    
-    WIDTH, HEIGHT  = 256, 256
-    surface = cairo.SVGSurface (fo, WIDTH, HEIGHT)
-    
-    ctx = cairo.Context (surface)
-    
-    svg = rsvg.Handle(file="test2.svg")
-    svg.render_cairo(ctx)
-    
-    surface.finish()
-
-Well, it works! test.svg comes in and comes out as test2.svg. I don't think it proves anything, but it's fun.
-
diff --git a/src/pythoncairopil.mdwn b/src/pythoncairopil.mdwn
deleted file mode 100644
index ffd8a57..0000000
--- a/src/pythoncairopil.mdwn
+++ /dev/null
@@ -1,21 +0,0 @@
-[[!meta title="PIL and Cairographics / PyCairo"]]
-
-Please note that the code below was to only blur an cairo image surface and thus ignores conversion from BGRA to RGBA to BGRA that is needed in other situations. Theoretically just replace RGBA with BGRA in frombuffer and tostring.
-
-    import cairo, Image, array
-
-    im = cairo.ImageSurface.create_from_png("img11.png")
-            
-    im1 = Image.frombuffer("RGBA",( im.get_width(),im.get_height() ),im.get_data(),"raw","RGBA",0,1)
-            
-    im1 = im1.filter(ImageFilter.BLUR)
-    im1 = im1.filter(ImageFilter.BLUR)
-    im1 = im1.filter(ImageFilter.SMOOTH_MORE) 
-            
-    #imgd = im1.tostring("raw","RGBA",0,1)
-    imgd = im1.tostring()
-    a = array.array('B',imgd)
-            
-    stride = self.width * 4
-    surface = cairo.ImageSurface.create_for_data (a, cairo.FORMAT_ARGB32,
-                                                  self.width, self.height, stride) 
diff --git a/src/quickframework.mdwn b/src/quickframework.mdwn
deleted file mode 100644
index 5718910..0000000
--- a/src/quickframework.mdwn
+++ /dev/null
@@ -1,70 +0,0 @@
-##A Quick GTK+ GNU/Linux Framework
-
-I got this from <http://www.tortall.net/mu/wiki/PyGTKCairoTutorial> : it's handy for running snippets of cairo code to see what's going on.
-
-This sample shows how to use a mask (a second source to filter the first source.)
-
-
-    #! /usr/bin/env python
-    import pygtk
-    pygtk.require('2.0')
-    import gtk, gobject, cairo
-    
-    # Create a GTK+ widget on which we will draw using Cairo
-    class Screen(gtk.DrawingArea):
-    
-        # Draw in response to an expose-event
-        __gsignals__ = { "expose-event": "override" }
-    
-        # Handle the expose-event by drawing
-        def do_expose_event(self, event):
-    
-            # Create the cairo context
-            cr = self.window.cairo_create()
-    
-            # Restrict Cairo to the exposed area; avoid extra work
-            cr.rectangle(event.area.x, event.area.y,
-                    event.area.width, event.area.height)
-            cr.clip()
-    
-            self.draw(cr, *self.window.get_size())
-    
-        def draw(self, cr, width, height):
-            # Fill the background with gray
-            cr.set_source_rgb(0.5, 0.5, 0.5)
-            cr.rectangle(0, 0, width, height)
-            cr.fill()
-    
-    # GTK mumbo-jumbo to show the widget in a window and quit when it's closed
-    def run(Widget):
-        window = gtk.Window()
-        window.connect("delete-event", gtk.main_quit)
-        widget = Widget()
-        widget.show()
-        window.add(widget)
-        window.present()
-        gtk.main()
-
-
-    
-    ## Do all your testing in Shapes ##
-
-
-    
-    class Shapes(Screen):
-        def draw(self, cr, width, height):
-            
-            ## This will draw using a mask.
-            cr.scale(width,height) #Without this line the mask does not seem to work!
-            self.linear = cairo.LinearGradient(0, 0, 1, 1)
-            self.linear.add_color_stop_rgb(0, 0, 0.3, 0.8)
-            self.linear.add_color_stop_rgb(1, 0, 0.8, 0.3)
-            
-            self.radial = cairo.RadialGradient(0.5, 0.5, 0.25, 0.5, 0.5, 0.5)
-            self.radial.add_color_stop_rgba(0, 0, 0, 0, 1)
-            self.radial.add_color_stop_rgba(0.5, 0, 0, 0, 0)
-            
-            cr.set_source(self.linear)
-            cr.mask(self.radial)       
-    
-    run(Shapes)
diff --git a/src/renderpdf.mdwn b/src/renderpdf.mdwn
deleted file mode 100644
index 790daf9..0000000
--- a/src/renderpdf.mdwn
+++ /dev/null
@@ -1,200 +0,0 @@
-##Rendering a PDF or PS file with cairo
-
-PDF files can be rendered to a cairo context using poppler. PS or EPS files can also be rendered to a cairo context by first converting to PDF using Ghostscript.
-
-When using a vector backend, the vectors and text in the PDF file are preserved in the output as vectors. There is no unnecessary rasterization.
-
-Compile the examples with:
-
-    gcc -o pdftops pdftops.c `pkg-config --cflags --libs cairo poppler-glib`
-    gcc -o pdftoimage pdftoimage.c `pkg-config --cflags --libs cairo poppler-glib`
-
-pdftops.c - Render a PDF file to a cairo PostScript surface.
-
-    #include <poppler.h>
-    #include <cairo.h>
-    #include <cairo-ps.h>
-
-    int main(int argc, char *argv[])
-    {
-        PopplerDocument *document;
-        PopplerPage *page;
-        double width, height;
-        GError *error;
-        const char *filename;
-        gchar *absolute, *uri;
-        int num_pages, i;
-        cairo_surface_t *surface;
-        cairo_t *cr;
-        cairo_status_t status;
-
-        if (argc != 2) {
-            printf ("Usage: pdf2cairo input_file.pdf\n");
-            return 0;
-        }
-
-        filename = argv[1];
-        g_type_init ();
-        error = NULL;
-
-        if (g_path_is_absolute(filename)) {
-            absolute = g_strdup (filename);
-        } else {
-            gchar *dir = g_get_current_dir ();
-            absolute = g_build_filename (dir, filename, (gchar *) 0);
-            free (dir);
-        }
-
-        uri = g_filename_to_uri (absolute, NULL, &error);
-        free (absolute);
-        if (uri == NULL) {
-            printf("poppler fail: %s\n", error->message);
-            return 1;
-        }
-
-        document = poppler_document_new_from_file (uri, NULL, &error);
-        if (document == NULL) {
-            printf("poppler fail: %s\n", error->message);
-            return 1;
-        }
-
-        num_pages = poppler_document_get_n_pages (document);
-
-        /* Page size does not matter here as the size is changed before
-         * each page */
-        surface = cairo_ps_surface_create ("output.ps", 595, 842);
-        cr = cairo_create (surface);
-        for (i = 0; i < num_pages; i++) {
-            page = poppler_document_get_page (document, i);
-            if (page == NULL) {
-                printf("poppler fail: page not found\n");
-                return 1;
-            }
-            poppler_page_get_size (page, &width, &height);
-            cairo_ps_surface_set_size (surface, width, height);
-            cairo_save (cr);
-            poppler_page_render_for_printing (page, cr);
-            cairo_restore (cr);
-            cairo_surface_show_page (surface);
-            g_object_unref (page);
-        }
-        status = cairo_status(cr);
-        if (status)
-            printf("%s\n", cairo_status_to_string (status));
-        cairo_destroy (cr);
-        cairo_surface_finish (surface);
-        status = cairo_surface_status(surface);
-        if (status)
-            printf("%s\n", cairo_status_to_string (status));
-        cairo_surface_destroy (surface);
-
-        g_object_unref (document);
-
-        return 0;
-    }
-
-
-pdftoimage.c - Render a one page of a PDF file to a cairo image surface.
-
-    #include <stdio.h>
-    #include <stdlib.h>
-    #include <poppler.h>
-    #include <cairo.h>
-
-    #define IMAGE_DPI 150
-
-    int main(int argc, char *argv[])
-    {
-        PopplerDocument *document;
-        PopplerPage *page;
-        double width, height;
-        GError *error;
-        const char *pdf_file;
-        const char *png_file;
-        gchar *absolute, *uri;
-        int page_num, num_pages;
-        cairo_surface_t *surface;
-        cairo_t *cr;
-        cairo_status_t status;
-
-        if (argc != 4) {
-            printf ("Usage: pdftoimage input_file.pdf output_file.png page\n");
-            return 0;
-        }
-
-        pdf_file = argv[1];
-        png_file = argv[2];
-        page_num = atoi(argv[3]);
-        g_type_init ();
-        error = NULL;
-
-        if (g_path_is_absolute(pdf_file)) {
-            absolute = g_strdup (pdf_file);
-        } else {
-            gchar *dir = g_get_current_dir ();
-            absolute = g_build_filename (dir, pdf_file, (gchar *) 0);
-            free (dir);
-        }
-
-        uri = g_filename_to_uri (absolute, NULL, &error);
-        free (absolute);
-        if (uri == NULL) {
-            printf("%s\n", error->message);
-            return 1;
-        }
-
-        document = poppler_document_new_from_file (uri, NULL, &error);
-        if (document == NULL) {
-            printf("%s\n", error->message);
-            return 1;
-        }
-
-        num_pages = poppler_document_get_n_pages (document);
-        if (page_num < 1 || page_num > num_pages) {
-            printf("page must be between 1 and %d\n", num_pages);
-            return 1;
-        }
-
-        page = poppler_document_get_page (document, page_num - 1);
-        if (page == NULL) {
-            printf("poppler fail: page not found\n");
-            return 1;
-        }
-
-        poppler_page_get_size (page, &width, &height);
-
-        /* For correct rendering of PDF, the PDF is first rendered to a
-         * transparent image (all alpha = 0). */
-        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
-                                              IMAGE_DPI*width/72.0,
-                                              IMAGE_DPI*height/72.0);
-        cr = cairo_create (surface);
-        cairo_scale (cr, IMAGE_DPI/72.0, IMAGE_DPI/72.0);
-        cairo_save (cr);
-        poppler_page_render (page, cr);
-        cairo_restore (cr);
-        g_object_unref (page);
-
-        /* Then the image is painted on top of a white "page". Instead of
-         * creating a second image, painting it white, then painting the
-         * PDF image over it we can use the CAIRO_OPERATOR_DEST_OVER
-         * operator to achieve the same effect with the one image. */
-        cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER);
-        cairo_set_source_rgb (cr, 1, 1, 1);
-        cairo_paint (cr);
-    
-        status = cairo_status(cr);
-        if (status)
-            printf("%s\n", cairo_status_to_string (status));
-
-        cairo_destroy (cr);
-        status = cairo_surface_write_to_png (surface, png_file);
-        if (status)
-            printf("%s\n", cairo_status_to_string (status));
-
-        cairo_surface_destroy (surface);
-
-        g_object_unref (document);
-
-        return 0;
-    }
diff --git a/src/svgtopycairo.mdwn b/src/svgtopycairo.mdwn
deleted file mode 100644
index 2b3ac6a..0000000
--- a/src/svgtopycairo.mdwn
+++ /dev/null
@@ -1,152 +0,0 @@
-##SVG paths can be parsed and turned into a seqence of cairo commands that re-draw them.
-
-This took a while, the pyparsing had me in knots, but now it's short and sweet. A fuller implementation of what can be done in SVG would be really nice. (Hint...)
-
-Make sure you pass it a very simple SVG file (from Inkscape is best) -- one that has had all the shapes reduced to paths. Oh, and keep your canvas 400 by 400 or it may draw clear off the screen. 
-
-**Depends on** 
-
-1. *elementree*: **import** elementree **as** myDearWatson :) It's a great module for slicing through XML.
-2. *pyparsing*: This module is deeply wonderful. I won't pretend to savvy even 1% of it, but it really does the job. They have a great mailing list where I got a lot of help. It let's you parse strings into lists and that is no small feat.
-
-**SVG Path element** 
-
-To briefly explain, inside an svg file (which is just xml) you'll find a tag named 'g' and under that one or more tags named 'path'. Inside path there is an element called 'd'; that's the actual path. It's formed like this: "COMMAND NUMBER COMMA NUMBER Optionally[NUMBER COMMA NUMBER a few more times]", where COMMAND is M for move, L for line, C for curve and Z for close path. There may be others, but that's what I tackled. Have a look at the pyparsing grammar which makes it fairly clear how different commands have different numbers behind them.
-
-Please forgive any bugs.
-
-
-    #!/usr/bin/env python
-    """\
-    Usage: drawsvg.py file
-    file  - one SVG file (from Inkscape!) that is all simple paths
-    
-    """
-    ##    svg2py Copyright  (C)  2007 Donn.C.Ingle
-    ##
-    ##    Contact: donn.ingle at gmail.com - I hope this email lasts.
-    ##
-    ##    This program is free software; you can redistribute it and/or modify
-    ##    it under the terms of the GNU General Public License as published by
-    ##    the Free Software Foundation; either version 2 of the License, or
-    ##     ( at your option )  any later version.
-    ##
-    ##    This program is distributed in the hope that it will be useful,
-    ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    ##    GNU General Public License for more details.
-    ##
-    ##    You should have received a copy of the GNU General Public License
-    ##    along with this program; if not, write to the Free Software
-    ##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-    ##
-    
-    import pygtk
-    pygtk.require('2.0')
-    import gtk, gobject, cairo
-    from pyparsing import *
-    import os, sys
-    from elementtree import ElementTree as et
-    
-    # Create a GTK+ widget on which we will draw using Cairo
-    class Screen(gtk.DrawingArea):
-    
-        # Draw in response to an expose-event
-        __gsignals__ = { "expose-event": "override" }
-    
-        # Handle the expose-event by drawing
-        def do_expose_event(self, event):
-    
-            # Create the cairo context
-            cr = self.window.cairo_create()
-    
-            # Restrict Cairo to the exposed area; avoid extra work
-            cr.rectangle(event.area.x, event.area.y,
-                    event.area.width, event.area.height)
-            cr.clip()
-    
-            self.draw(cr, *self.window.get_size())
-    
-        def draw(self, cr, width, height):
-            # Fill the background with gray
-            cr.set_source_rgb(0.5, 0.5, 0.5)
-            cr.rectangle(0, 0, width, height)
-            cr.fill()
-    
-    # GTK mumbo-jumbo to show the widget in a window and quit when it's closed
-    def run(Widget):
-        window = gtk.Window()
-        window.set_size_request(400, 400)
-        window.connect("delete-event", gtk.main_quit)
-        widget = Widget()
-        widget.show()
-        window.add(widget)
-        window.present()
-        gtk.main()
-    
-    ## Do the drawing ##
-    
-    class Shapes(Screen):
-        def draw(self, ctx, width, height):
-            
-            #Build a string of cairo commands
-            cairo_commands = ""
-            command_list = []
-            for tokens in paths:
-                for command,couples in tokens[:-1]: #looks weird, but it works :)
-                    c = couples.asList()
-                    if command == "M":
-                        cairo_commands += "ctx.move_to(%s,%s);" % (c[0],c[1])
-                    if command == "C":
-                        cairo_commands += "ctx.curve_to(%s,%s,%s,%s,%s,%s);" % (c[0],c[1],c[2],c[3],c[4],c[5])
-                    if command == "L":
-                        cairo_commands += "ctx.line_to(%s,%s);" % (c[0],c[1])
-                    if command == "Z":
-                        cairo_commands += "ctx.close_path();"
-        
-                command_list.append(cairo_commands) #Add them to the list
-                cairo_commands = ""
-            #Draw it. Only stroked, to fill as per the SVG drawing is another whole story.
-            ctx.set_source_rgb(1,0,0)    
-            for c in command_list:
-                exec(c)
-            ctx.stroke()
-
-    
-    #Check args:
-    if len(sys.argv) < 2:
-        raise SystemExit(__doc__)
-    file = sys.argv[1]
-    
-    ## Pyparsing grammar:
-    ## With HUGE help from Paul McGuire <paul at alanweberassociates.com>
-    ## Thanks!
-    dot = Literal(".")
-    comma = Literal(",").suppress()
-    floater = Combine(Optional("-") + Word(nums) + dot + Word(nums))
-    ## Unremark to have numbers be floats rather than strings.
-    #floater.setParseAction(lambda toks:float(toks[0]))
-    couple = floater + comma + floater
-    M_command = "M" + Group(couple)
-    C_command = "C" + Group(couple + couple + couple)
-    L_command = "L" + Group(couple)
-    Z_command = "Z"
-    svgcommand = M_command | C_command | L_command | Z_command
-    phrase = OneOrMore(Group(svgcommand)) 
-    
-    ## Find and open the svg file
-    xml_file = os.path.abspath(__file__)
-    xml_file = os.path.dirname(xml_file)
-    xml_file = os.path.join(xml_file, file)
-    
-    tree = et.parse(xml_file)
-    
-    ns = "http://www.w3.org/2000/svg" #The XML namespace.
-    paths = []
-    for group in tree.getiterator('{%s}g' % ns):
-        for e in group.getiterator('{%s}path' % ns):
-            p = e.get("d")
-            tokens = phrase.parseString(p.upper())
-            paths.append(tokens) # paths is a global var.
-    
-    run(Shapes)
diff --git a/src/win32quickstart.mdwn b/src/win32quickstart.mdwn
deleted file mode 100644
index 571fe37..0000000
--- a/src/win32quickstart.mdwn
+++ /dev/null
@@ -1,169 +0,0 @@
-[[!meta title="Win32 Quickstart"]]
-Back to [[cookbook]]
-
-##Python
-The following is a minimal windows application that uses cairo. It has double buffering and uses the PyWin32 library.
-
-    from win32api import *
-    try:
-        from winxpgui import *
-    except ImportError:
-        from win32gui import *
-        
-    import win32con
-    import sys, os
-    import cairo
-    
-    def WebColour(sCol):
-        #print sCol
-        ic = [int(sCol[i:i+2], 16)/255.0 for i in range(1, 7, 2)]
-        #print ic
-        return ic
-    
-    def roundedRectangle(cr,x,y,w,h,radius_x=5,radius_y=5):
-        #from mono moonlight aka mono silverlight
-        #test limits (without using multiplications)
-        # http://graphics.stanford.edu/courses/cs248-98-fall/Final/q1.html
-        ARC_TO_BEZIER = 0.55228475
-        if radius_x > w - radius_x:
-            radius_x = w / 2
-        if radius_y > h - radius_y:
-            radius_y = h / 2
-    
-        #approximate (quite close) the arc using a bezier curve
-        c1 = ARC_TO_BEZIER * radius_x
-        c2 = ARC_TO_BEZIER * radius_y
-    
-        cr.new_path();
-        cr.move_to ( x + radius_x, y)
-        cr.rel_line_to ( w - 2 * radius_x, 0.0)
-        cr.rel_curve_to ( c1, 0.0, radius_x, c2, radius_x, radius_y)
-        cr.rel_line_to ( 0, h - 2 * radius_y)
-        cr.rel_curve_to ( 0.0, c2, c1 - radius_x, radius_y, -radius_x, radius_y)
-        cr.rel_line_to ( -w + 2 * radius_x, 0)
-        cr.rel_curve_to ( -c1, 0, -radius_x, -c2, -radius_x, -radius_y)
-        cr.rel_line_to (0, -h + 2 * radius_y)
-        cr.rel_curve_to (0.0, -c2, radius_x - c1, -radius_y, radius_x, -radius_y)
-        cr.close_path ()
-    
-    
-    class MainWindow(object):
-        def __init__(self):        
-            message_map = {
-                    win32con.WM_DESTROY: self.OnDestroy,
-                    win32con.WM_PAINT: self.OnPaint,
-                    win32con.WM_SETCURSOR: self.OnCursor,
-                    win32con.WM_ERASEBKGND: self.OnBackgroundErase,
-                    win32con.WM_LBUTTONDOWN: self.OnClick,
-                    win32con.WM_KEYUP: self.OnKey,
-                    #win32con.WM_COMMAND: self.OnCommand,
-                    #win32con.WM_USER+20 : self.OnTaskbarNotify,
-                    # owner-draw related handlers.
-                    #win32con.WM_MEASUREITEM: self.OnMeasureItem,
-                    #win32con.WM_DRAWITEM: self.OnDrawItem,
-            }
-            # Register the Window class.
-            wc = WNDCLASS()
-            hinst = wc.hInstance = GetModuleHandle(None)
-            self.hinst = hinst
-            wc.lpszClassName = "CairoWindow"
-            wc.lpfnWndProc = message_map # could also specify a wndproc.
-            classAtom = RegisterClass(wc)
-            # Create the Window.
-            style = win32con.WS_THICKFRAME | win32con.WS_MAXIMIZEBOX | win32con.WS_MINIMIZEBOX | win32con.WS_SYSMENU | win32con.WS_VISIBLE
-            self.hwnd = CreateWindow( classAtom, "Cairo is the greatest thing!", style, \
-                    0, 0, 550, 350, \
-                    0, 0, hinst, None)
-            UpdateWindow(self.hwnd)
-            
-            
-        def OnKey(self, hWnd, msg, wParam, lparam):
-            if wParam == 38: #up
-                print "up"
-            elif wParam == 40: #down
-                print "down"
-            
-        def OnClick(self, hWnd, msg, wparam, lparam):
-            x = LOWORD(lparam)
-            y = HIWORD(lparam) 
-                    
-        def Render(self):
-            try:
-                InvalidateRect(self.hwnd, None, True)
-                return True
-            except:
-                print "That didn't work"
-                return False
-    
-        def OnPaint(self, hWnd, msg, wparam, lparam):   
-            hdc, ps = BeginPaint(hWnd)
-            rc = GetClientRect(hWnd)
-            left, top, right, bottom = rc            
-            
-            width = right - left
-            height = bottom - top
-            x = left
-            y = top 
-            
-            _buffer = CreateCompatibleDC(hdc) 
-            #Double Buffer Stage 1
-            hBitmap = CreateCompatibleBitmap(hdc,width,height)
-            hOldBitmap = SelectObject(_buffer, hBitmap )
-            
-            
-            surf = cairo.Win32Surface(_buffer)
-            ctx = cairo.Context(surf) 
-            
-            ctx.set_source_rgb(1,1,1)
-            ctx.paint()
-            
-            
-            roundedRectangle(ctx, 50, 50, 250, 250, 10, 10)
-            clr = WebColour("#F0FEE9")        
-            ctx.set_source_rgb(clr[0],clr[1],clr[2])
-            ctx.fill_preserve()
-            clr = WebColour("#B3FF8D")        
-            ctx.set_source_rgb(clr[0],clr[1],clr[2])
-            ctx.stroke()        
-                
-            ctx.set_source_rgb(0,0,0)
-            ctx.select_font_face("Arial",cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
-            ctx.set_font_size(10)    
-    
-            txt = "Cairo is the greatest thing!"
-                
-            ctx.move_to(5,10)        
-            ctx.show_text(txt)
-            
-            surf.finish()
-            
-            BitBlt(hdc,0, 0, width,  height,
-              _buffer, x, y, win32con.SRCCOPY) 
-            
-            SelectObject( _buffer, hOldBitmap ) 
-            DeleteObject( hBitmap ) 
-            DeleteDC( _buffer )               
-            
-            EndPaint(hWnd,ps)        
-            
-        def OnCursor(self, hwnd, msg, wparam, lparam):
-            #IDC_HAND = 32649
-            #IDC_ARROW
-            cur_normal = LoadCursor(0, win32con.IDC_ARROW)
-            SetCursor(cur_normal)
-            
-        def OnBackgroundErase(self, hwnd, msg, wparam, lparam):
-            return False
-    
-            
-        def OnDestroy(self, hwnd, msg, wparam, lparam):
-            #nid = (self.hwnd, 0)
-            #Shell_NotifyIcon(NIM_DELETE, nid)
-            PostQuitMessage(0) # Terminate the app. 
-            print "Exited."
-               
-            
-    w=MainWindow()
-    PumpMessages()
-          
-##Other?
\ No newline at end of file


More information about the cairo-commit mailing list