Permalink
Browse files

Added free and READ ME LIKE ONE OF YOUR GERMAN HOUNDS #LD48

  • Loading branch information...
1 parent e5eff76 commit b74fb154f30809ae5c6e67b02e89170af3a2a3ad Amos Wenger committed Dec 17, 2011
Showing with 47 additions and 3 deletions.
  1. +43 −0 README.md
  2. +4 −3 source/rsvg.ooc
View
43 README.md
@@ -0,0 +1,43 @@
+
+## librsvg bindings for ooc
+
+librsvg is this very neat library that loads .svg files really easily.
+
+And these are ooc bindings for it.
+
+My use case was clearly to render to a cairo context, so that's all I bound.
+Patches welcome though, if you want to render to a GdkPixbuf or something like that.
+
+## Usage
+
+
+```ooc
+SomeApp: class {
+
+ svg: Svg
+
+ // loading it
+ load: func {
+ svg = Svg new("cutegraphic.svg")
+ }
+
+ // rendering it
+ render: func (cr: Context) {
+ // remember, in cairo you can move stuff
+ // around with cr translate(x, y)
+ // don't forget to cr save() before
+ // and cr restore() before, so you don't mess
+ // up your context
+ svg render(cr)
+ }
+
+ free: func {
+ // don't forget to free it, or it'll leak in the
+ // long run - svg handles are not GC-collected
+ svg free()
+ }
+
+}
+```
+
+That's it. Have fun!
View
7 source/rsvg.ooc
@@ -3,7 +3,7 @@ use rsvg, cairo
include librsvg/rsvg, librsvg/rsvg-cairo
import cairo/Cairo
-SvgHandle: cover from RsvgHandle * {
+Svg: cover from RsvgHandle * {
/**
* Load an .svg file from an .svg file
@@ -15,7 +15,8 @@ SvgHandle: cover from RsvgHandle * {
render: extern(rsvg_handle_render_cairo) func (cr: Context)
-}
+ free: extern(rsvg_handle_free) func
-rsvg_handle_new_from_file: extern func (path: CString, error: Pointer*) -> SvgHandle
+}
+rsvg_handle_new_from_file: extern func (path: CString, error: Pointer*) -> Svg

0 comments on commit b74fb15

Please sign in to comment.