SVG module

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

SVG module

Dirk Laurie-2
I wish to generate SVG drawings but have no appetite for programs like Inkscape that require me to place every component manually.

`luarocks search svg` and `luarocks search cairo` both turn up nothing,

According to its repository (thank Google!), "EzSVG just wraps the SVG language in a Lua way", but "Interface is not yet finalized and some features are still missing." The author last updated the code six years ago.

Nevertheless, EzSVG has the sort of feel that I want, e.g.
EzSVG.Line(100, 500, 900, 500):rotate(r, 500, 500)
Before I spend too much time on it, though, I wonder whether some list member has a favorite SVG generator that knocks this one for a loop and is currently being maintained.

-- Dirk
Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Luiz Henrique de Figueiredo
> I wonder whether some list
> member has a favorite SVG generator that knocks this one for a loop and is
> currently being maintained.

There is an SVG driver (and much more) in the code for Diego's 2D
graphics course:

http://w3.impa.br/~diego/teaching/2018.0/index.html

Go to Materials and get src-1.03.zip.

Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Ką Mykolas
I wonder if You could use LuaTex...

On Mon, Apr 16, 2018 at 1:16 PM, Luiz Henrique de Figueiredo <[hidden email]> wrote:
> I wonder whether some list
> member has a favorite SVG generator that knocks this one for a loop and is
> currently being maintained.

There is an SVG driver (and much more) in the code for Diego's 2D
graphics course:

http://w3.impa.br/~diego/teaching/2018.0/index.html

Go to Materials and get src-1.03.zip.


Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Axel Kittenberger
I wonder if You could use LuaTex...

I don't know what Dirk's use case actually is, but if the context would eventually be TeX, that sounds like a calling for TikZ -- programmatically creation of vector graphics. Albeit neither Lua nor SVG required. 
Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Dirk Laurie-2
In reply to this post by Ką Mykolas
2018-04-16 12:22 GMT+02:00 Ką Mykolas <[hidden email]>:
>
> I wonder if You could use LuaTex...
>

LuaTeX does not support SVG directly at present — all sorts of cute
tricks of course, one of them even (ugh!) covertly invoking Inkscape
in batch mode. Naturally, anything written in Lua can be executed in
LuaTeX too.

  TeXLua = TeX + Lua + [many modules] - lua_interactive

Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Dirk Laurie-2
In reply to this post by Axel Kittenberger
2018-04-16 12:31 GMT+02:00 Axel Kittenberger <[hidden email]>:
>> I wonder if You could use LuaTex...
>
> I don't know what Dirk's use case actually is, but if the context would
> eventually be TeX, that sounds like a calling for TikZ -- programmatically
> creation of vector graphics. Albeit neither Lua nor SVG required.

My main use case is including charts into web pages but also in
printable documents, which may bne made by TeX or by Word. SVG has the
advantage that my browser can display it directly. TeX is the least
convenient for this purpose, but I am not allergic to Makefiles that
do the required conversion to e.g. PNG.

Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Dirk Laurie-2
In reply to this post by Luiz Henrique de Figueiredo
2018-04-16 12:16 GMT+02:00 Luiz Henrique de Figueiredo <[hidden email]>:

>> I wonder whether some list
>> member has a favorite SVG generator that knocks this one for a loop and is
>> currently being maintained.
>
> There is an SVG driver (and much more) in the code for Diego's 2D
> graphics course:
>
> http://w3.impa.br/~diego/teaching/2018.0/index.html
>
> Go to Materials and get src-1.03.zip.

Thanks. I am impressed.

Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Hisham
In reply to this post by Dirk Laurie-2
On 16 April 2018 at 06:54, Dirk Laurie <[hidden email]> wrote:
> I wish to generate SVG drawings but have no appetite for programs like
> Inkscape that require me to place every component manually.
>
> `luarocks search svg` and `luarocks search cairo` both turn up nothing,

Cairo is available as part of the lgi bindings:

https://luarocks.org/modules/pavouk/lgi

-- Hisham

Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Dirk Laurie-2
2018-04-16 16:16 GMT+02:00 Hisham <[hidden email]>:
> On 16 April 2018 at 06:54, Dirk Laurie <[hidden email]> wrote:
>> I wish to generate SVG drawings but have no appetite for programs like
>> Inkscape that require me to place every component manually.
>>
>> `luarocks search svg` and `luarocks search cairo` both turn up nothing,
>
> Cairo is available as part of the lgi bindings:
>
> https://luarocks.org/modules/pavouk/lgi

Thanks. Installed and built straightaway on Lua 5.3.

-- Dirk

Reply | Threaded
Open this post in threaded view
|

Re: SVG module

aryajur
Although I have not tried it the Canvas Draw Library seems to have a SVG driver as well - http://webserver2.tecgraf.puc-rio.br/cd/


On Mon, Apr 16, 2018, 7:49 AM Dirk Laurie <[hidden email]> wrote:
2018-04-16 16:16 GMT+02:00 Hisham <[hidden email]>:
> On 16 April 2018 at 06:54, Dirk Laurie <[hidden email]> wrote:
>> I wish to generate SVG drawings but have no appetite for programs like
>> Inkscape that require me to place every component manually.
>>
>> `luarocks search svg` and `luarocks search cairo` both turn up nothing,
>
> Cairo is available as part of the lgi bindings:
>
> https://luarocks.org/modules/pavouk/lgi

Thanks. Installed and built straightaway on Lua 5.3.

-- Dirk

Reply | Threaded
Open this post in threaded view
|

Re: SVG module

Dirk Laurie-2
I think that perhaps I should give an example of EzSVG, since despite
all the suggestions, that still is closest to what I am looking for.

It is not a backend, in the sense that one is coding in some other
abstraction layer and SVG is an implementation layer. Neither does it
render SVG into GTk or whatever.

It requires you to think in terms of SVG constructions, but expressed
as idiomatic-looking Lua code instead of as an XML variant.

-- create a group (very handy, also stays a group in Inkscape/Illustrator)
local group = EzSVG.Group()

for r=0,360, 10 do
    -- create a line and add a transform (rotation with r degrees,
centered on 500/500)
    local line = EzSVG.Line(100, 500, 900, 500):rotate(r, 500, 500)
    -- add it to the group
    group:add(line)
end

-- add the group to the document
doc:add(group)

The CamelCase annoys me, and I would be happier with table arguments, i.e.

   local line = ezsvg.line{x1=100,y1=500;
x2=900,y2=500}:rotate{angle=r; x=500,y=500}

but the basic concept looks good.

So I am looking for a fuller-featured, well-supported library a;omg
similar lines. Otherwise I'll just fork the repository.