lua-users home
lua-l archive

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



I'll be doing some SVG graphics work and applied some Lumikki-kind thinking to making a simple SVG generation tool, in Lua.

Currently available only by svn checkout, from:

	svn co svn://slugak.dyndns.org/public/2009/Svg

Here's one of the sample files:

--
-- ELLIPSE1.LUA
--

require "svgcore"

local rgb= assert(svg.rgb)

print( svg.document(
    svg.default{ stroke_dasharray={2,2},
        --
        svg.ellipse{ {80,110}, {75,105}, fill="#538" },
svg.ellipse{ {80,110}, {60,40}, fill="black", stroke="red", stroke_width=25 }, svg.ellipse{ {80,110}, {35,20}, fill="#538", stroke="yellow", stroke_width=25 }, svg.ellipse{ {80,50}, {40,30}, fill="red", stroke="black", stroke_width=25 }, svg.ellipse{ {80,50}, {30,20}, fill="orange", stroke="red", stroke_width=10 }, svg.ellipse{ {80,170}, {40,30}, fill="yellow", stroke="orange", stroke_width=25 }, svg.ellipse{ {80,170}, {30,20}, fill="red", stroke="black", stroke_width=10 }
    }
) )

The idea is that Lua syntax is a bit nicer to craft than XML, but this also allows programmatic creation of macro-like objects (functions that create graphical objects) that can be turned around, copied etc.. SVG has a "uses" element for that, but this is more easy on the eyes (clearer code).

I post this mostly to inform if anyone has a similar need. Be my guest and use it. Haven't decided the license yet.

Btw, SVG + JavaScript is a perfect blend for making visually good- looking UI applications. SVG in theory support any scripting language, so maybe we can at one day have SVG+Lua viewer.

-asko