SVG generation gem?

R

Rick DeNatale

I've recently started playing with an Epilog laser cutter, and I find
myself wanting to programmatically generate SVG files.

I googled for ruby and svg this morning and although there seem to be
a few old stagnant efforts, there's nothing too useful I could find.

I suppose it wouldn't be too hard to start cooking something up using
Jim Wierich's xml builder gem, but before I got started I wanted to
see if there was anything I missed.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
G

Glen Holcomb

I've recently started playing with an Epilog laser cutter, and I find
myself wanting to programmatically generate SVG files.

I googled for ruby and svg this morning and although there seem to be
a few old stagnant efforts, there's nothing too useful I could find.

I suppose it wouldn't be too hard to start cooking something up using
Jim Wierich's xml builder gem, but before I got started I wanted to
see if there was anything I missed.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
I had a similar experience a few months ago. I was looking specifically to
generate graphs from log data and found a passable library but I don't thin=
k
it's still active and it is a bit of a pain. It is working for my very
specific and not too important needs, but I'd probably go from scratch if i=
t
were important or needed to be flexible.

--=20
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can=92t hear a word you=92re saying."

-Greg Graffin (Bad Religion)
 
W

William Rutiser

Rick said:
I've recently started playing with an Epilog laser cutter, and I find
myself wanting to programmatically generate SVG files.

I googled for ruby and svg this morning and although there seem to be
a few old stagnant efforts, there's nothing too useful I could find.

I suppose it wouldn't be too hard to start cooking something up using
Jim Wierich's xml builder gem, but before I got started I wanted to
see if there was anything I missed.
Topher Cyll's book, "Practical Ruby Projects; Ideas for the Eclectic
Programmer", has a chapter that generates animations with SVG.
SVG is wrapped in an SVGObject class but it is only developed to the
extent needed for the example project. It may give you a start.

See http://www.cyll.org/
 
B

Benoit Daloze

I've recently started playing with an Epilog laser cutter, and I find
myself wanting to programmatically generate SVG files.

I googled for ruby and svg this morning and although there seem to be
a few old stagnant efforts, there's nothing too useful I could find.

I suppose it wouldn't be too hard to start cooking something up using
Jim Wierich's xml builder gem, but before I got started I wanted to
see if there was anything I missed.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

I coded my own SVG class a few years ago:
http://github.com/eregon/Classes/blob/master/xml/svg.rb

It's basically replacing xml tags by their name (as methods) and using
arguments in a better way.

SVGPath was a fun try to go further, allowing to build step-by-step a path.

I wanted to add animations which could be rendered using either
<animate> tags or JS.

I would enjoy to improve it and/or collaborate.

Please say me if this could be a start for what you are looking for.

Regards,
B.D.
 
R

Rick DeNatale

Topher Cyll's book, "Practical Ruby Projects; Ideas for the Eclectic
Programmer", has a chapter that generates animations with SVG.
SVG is wrapped in an SVGObject class but it is only developed to the extent
needed for the example project. It may give you a start.

See http://www.cyll.org/

I've been thinking about this a bit more, and for my purposes, which
is having an api to describe a static vector graphic for use with
things like laser cutters and other cam-like stuff with takes svg
input, that it might be interesting to try to use the same API as
Prawn for generating the graphics object model.

The graphics models for pdf and svg seem to be quite similar, not
surprising given Adobe's major input to SVG. I tend to see both as a
declarative expression of the Postscript drawing model, or at least
starting there.

I notice that there's at least one Prawn svg 'renderer' out there, but
it goes in the opposite direction I'm pursuing in that it renders svg
into prawn calls, rather than generating SVG from the prawn document
model.

I haven't investigated any of this really deeply, but it may be
possible to write something which extends and reuses most of Prawn but
with a different class of Document and some associated classes which
render SVG rather than PDF.

Perhaps Gregory Brown or one of the other core Prawn contributors will
see this and comment?
--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
 
G

Gregory Brown

I haven't investigated any of this really deeply, but it may be
possible to write something which extends and reuses most of Prawn but
with a different class of Document and some associated classes which
render SVG rather than PDF.

Perhaps Gregory Brown or one of the other core Prawn contributors will
see this and comment?

Thanks to JEG2, I now know about this thread. :)

Right now we're not in a super stellar state for dropping in an
alternate renderer, but it's a huge goal of ours and we're heading in
that direction. A sufficiently interesting use case such as this
would really help. Anyone looking to wrap Prawn's high level
features onto a different backend format, please do contact us via the
Prawn mailing list, we will be happy to make the refactorings
necessary to make this easy:

http://groups.google.com/group/prawn-ruby
 
W

William Rutiser

Rick said:
I've been thinking about this a bit more, and for my purposes, which
is having an api to describe a static vector graphic for use with
things like laser cutters and other cam-like stuff with takes svg
input, that it might be interesting to try to use the same API as
Prawn for generating the graphics object model.

The graphics models for pdf and svg seem to be quite similar, not
surprising given Adobe's major input to SVG. I tend to see both as a
declarative expression of the Postscript drawing model, or at least
starting there.

I notice that there's at least one Prawn svg 'renderer' out there, but
it goes in the opposite direction I'm pursuing in that it renders svg
into prawn calls, rather than generating SVG from the prawn document
model.

I haven't investigated any of this really deeply, but it may be
possible to write something which extends and reuses most of Prawn but
with a different class of Document and some associated classes which
render SVG rather than PDF.

Perhaps Gregory Brown or one of the other core Prawn contributors will
see this and comment?
I am also interested in generating vector graphics with Ruby. One thing
I have peeked into is Cairo which advertises Ruby bindings. Cairo itself
seems to be widely used and is intended to support multiple back ends
including SVG.

Cairo is used by Shoes and Gnome. The Ruby bindings are called rcairo
but the api docs are mostly in Japanese.

-- Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top