[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: SVG generation in Lua
- From: "Stuart P. Bentley" <stuart@...>
- Date: Sun, 16 Aug 2009 01:45:50 -0700
Woah, crazy! Not only was I wondering about SVG generation in Lua the other
day, but I've also written a modeling framework that works almost exactly
like this!
function hq.thriller()
local waist=.825
local shoulders=.3
local shouldout=.1
local blackw=.05
local headheight=.15
local hairw=.5
local hairh=.4
local neckout=.15
local hcenter=right/2
color(1,1,1)
rect(left,top,right,bottom)
--hair
color(.02,.01,0)
cutcircle({hcenter,headheight},hairw,25,160,hairh)
cutcircle({hcenter,headheight},hairw,120,230,hairh)
--base jacket
color(1,0,0)
rect(left,top+shoulders,right,bottom)
polygon(
{left-shouldout,shoulders},
{right+shouldout,shoulders},
{right-hcenter/2,bottom},
{left+hcenter/2,bottom})
--lines
color(0,0,0)
parallelogram(
{left-blackw,shoulders},
{hcenter-blackw,bottom},
blackw)
parallelogram(
{right,shoulders},
{hcenter,bottom},
blackw)
polygon(
{hcenter-neckout,shoulders},
{hcenter+neckout,shoulders},
{hcenter,waist}
)
end
(This gets passed to a function "model", which uses as an environment a
table of primitive-generating functions. The result is attached, and yes,
due to a slight miscalculation I haven't bothered to fix, the "hair" wedges
above the top of the "head".)
Also, would SVG work as a driver for CanvasDraw?
--------------------------------------------------
From: "Asko Kauppi" <askok@dnainternet.net>
Sent: Wednesday, August 12, 2009 A12:32
Newsgroups: gmane.comp.lang.lua.general
To: "Lua list" <lua@bazar2.conectiva.com.br>
Subject: Re: SVG generation in Lua
I've planned a separate svggraph module for such. This is just a start.
So, not yet.
- asko
On 12.8.2009, at 9.59, Lloyd <lloyd@cdactvm.in> wrote:
Is there any method available to plot interactive graphs using this
method? For example if we have millions of items in a graph, it will be
difficult to present in a single screen. In that case, we will represent
items as very small items, and will give the user more option to zoom
the graph. Like this, is it possible to draw an interactive graph?
Thanks,
Lloyd
On Wed, 12 Aug 2009 11:43:23 +0530, Asko Kauppi <askok@dnainternet.net>
wrote:
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
______________________________________
Scanned and protected by Email scanner
Attachment:
thriller.png
Description: PNG image