Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit b74fb154f30809ae5c6e67b02e89170af3a2a3ad 1 parent e5eff76
Amos Wenger (old) authored
Showing with 47 additions and 3 deletions.
  1. +43 −0 README.md
  2. +4 −3 source/rsvg.ooc
43 README.md
View
@@ -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!
7 source/rsvg.ooc
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.