SVG generation gem?

Discussion in 'Ruby' started by Rick DeNatale, Jul 30, 2010.

  1. 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
    Rick DeNatale, Jul 30, 2010
    #1
    1. Advertising

  2. Rick DeNatale

    Glen Holcomb Guest

    On Fri, Jul 30, 2010 at 9:59 AM, Rick DeNatale <>wro=
    te:

    > 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)
    Glen Holcomb, Jul 30, 2010
    #2
    1. Advertising

  3. Rick DeNatale wrote:
    > 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/
    William Rutiser, Jul 30, 2010
    #3
  4. On 30 July 2010 17:59:31 UTC+2, Rick DeNatale <> wrote:
    > 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.
    Benoit Daloze, Jul 30, 2010
    #4
  5. On Fri, Jul 30, 2010 at 2:11 PM, William Rutiser <> wrote:
    > Rick DeNatale wrote:
    >>
    >> 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/


    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
    Rick DeNatale, Jul 31, 2010
    #5
  6. On Sat, Jul 31, 2010 at 11:38 AM, Rick DeNatale <> wrote:
    > On Fri, Jul 30, 2010 at 2:11 PM, William Rutiser <> wrote:


    > 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
    Gregory Brown, Jul 31, 2010
    #6
  7. Re: SVG generation gem? Cairo?

    Rick DeNatale wrote:
    > On Fri, Jul 30, 2010 at 2:11 PM, William Rutiser <> wrote:
    >
    >> Rick DeNatale wrote:
    >>
    >>> 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/
    >>

    >
    > 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
    William Rutiser, Aug 2, 2010
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arne Nordmann
    Replies:
    0
    Views:
    503
    Arne Nordmann
    Jun 28, 2004
  2. Mardagg
    Replies:
    0
    Views:
    790
    Mardagg
    May 12, 2006
  3. Mardagg
    Replies:
    0
    Views:
    639
    Mardagg
    May 12, 2006
  4. milof83

    svg to svg saving problem

    milof83, Aug 18, 2006, in forum: Java
    Replies:
    1
    Views:
    800
    Roland de Ruiter
    Aug 18, 2006
  5. Austin 7873
    Replies:
    5
    Views:
    172
    Eric Hodel
    Jan 27, 2007
Loading...

Share This Page