lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 09.08.2010 08:23, Wesley Smith wrote:
> Cairo graphics has an SVG surface backend:
> http://cairographics.org/manual/

AFAIR this is only to create SVG surface (ie output file) using Cairo,
not for generating images for already generated svg file.

> There are some luacairo bindings floating around.
> wes
> 
> On Mon, Aug 9, 2010 at 7:48 AM, Stuart P. Bentley <stuart@testtrack4.com> wrote:
>> I've been thinking about Processing
>> (http://en.wikipedia.org/wiki/Processing_(programming_language)) lately and
>> how it could be reimplemented with Lua, but I've hit a stumbling block with
>> the example given on the Wikipedia page: is there any library in Lua that
>> allows for SVG manipulation like that?

There are 2 issues: SVG rendering and XML processing.

You can render your svg file using Gtk bindings, like
gdk.Pixbuf.new_from_file() or even better gdk.PixbufLoader()

If you are using lgob, just try out this example:
http://gitorious.org/lgob/mainline/blobs/master/examples/Pixbuf.lua

(change 'tux.png' to 'Blank_US_Map.svg')

The line:    PShape state = usa.getChild(states[i]);
manipulates XML (gets subset of the main file), so you could use any XML
binding (check this: http://lua-users.org/wiki/LuaXml ) to get subset of
a SVG file.

Then you could use gdk.PixbufLoader().write(svg) to generate your new
object.

Regards,
	miko