From: Yotta Meter on
The example I'm looking for in regards to ruby/SVG differs from the
previous questions. I have an SVG document generated from Adobe
Illustrator, and I'd like to not only display the SVG document using
ruby, I'd like to modify it within the ruby program and re-display the
image.

As an example, say I have two nodes connected with and edge, node0,
node1, and theEdge. In Illustrator I draw the two nodes and edge with
the color black. I write out the file to file.svg

I'm able to to open the file in a web browser and view the image
correctly.

For ruby, I'd like to be able to use Tk to show the image on a canvas.
Once an event is processed, I'd like to change the color of node0 to red
from black, with node1 and theEdge staying black. I'm assuming I could
use REXML to change the property of node0. My hope is then to re-display
the SVG image, replacing the original.

Ideally I'd like to be able to detect mouse over events on individual
elements of the SVG document.

I'm going to start attempting to do this - if I am going down a rathole,
I'd appreciate feedback!

Thanks in advance.
--
Posted via http://www.ruby-forum.com/.

From: Arndt Roger Schneider on
Yotta Meter schrieb:

>The example I'm looking for in regards to ruby/SVG differs from the
>previous questions. I have an SVG document generated from Adobe
>Illustrator, and I'd like to not only display the SVG document using
>ruby, I'd like to modify it within the ruby program and re-display the
>image.
>
>As an example, say I have two nodes connected with and edge, node0,
>node1, and theEdge. In Illustrator I draw the two nodes and edge with
>the color black. I write out the file to file.svg
>
>I'm able to to open the file in a web browser and view the image
>correctly.
>
>For ruby, I'd like to be able to use Tk to show the image on a canvas.
>Once an event is processed, I'd like to change the color of node0 to red
>from black, with node1 and theEdge staying black. I'm assuming I could
>use REXML to change the property of node0. My hope is then to re-display
>the SVG image, replacing the original.
>
>Ideally I'd like to be able to detect mouse over events on individual
>elements of the SVG document.
>
>I'm going to start attempting to do this - if I am going down a rathole,
>I'd appreciate feedback!
>
>Thanks in advance.
>
>

Jeszra
http://jeszra.sourceforge.net/

can import and export from and to SVG & Tk.
A DOM-tree is being used for importing SVG in Tk.
The approach is however somewhat different from
your description --I assume you do want to tightly couple
SVG and Tk?

Jeszra always generates code, which in turn generates the
graphics--allowing code-reviews on both sides.

SVG is saturated with features, only a subset of
which can be mapped 1:1 in Tk, and forget the Tk canvas.

Jeszra's code generation targets tkpath 0.2 or 0.3 when importing SVG,
and exports from tk canvas, tkpath, tkzinc, text ...

There is some perl-code, on cpan, available to import SVG
into tkzinc... the project is abondend and incomplete.
There is another SVG export project, from Tk canvas,
written in python (search the tkinter wiki).


Technically not yet feasible:
clippath, textpath, mpath, marker, tref,
filters, pattern, user model for radial gradients.
SVG-fonts, smil.

http://jeszra.sourceforge.net/jeszra/vectordesign.html
http://jeszra.sourceforge.net/jeszra/Jeszra_TechnicalNotes.html#d0e9905

-roger

From: Yotta Meter on
Maybe I can read the file.svg, modify it, and then write it as a temp
file, and then import it using Jeszra?

I guess I'm not clear on the code generation - I just think of svg as
sort of a text based bitmap. I'll have to take a look at it and try it
out.
--
Posted via http://www.ruby-forum.com/.

From: Yotta Meter on
Jeszra looks like a GUI Builder - it's interesting, but really I'm just
planning a simple canvas, and would like the ability to put SVG images
on that canvas, modify them, then re-render.

I'll probably look at Jeszra for another problem though, thanks.
--
Posted via http://www.ruby-forum.com/.

From: Mark T on
Ruby is the Right language for pretty much everything.
Though if the delivery vehicle for your project could be a browser,
then javascript is your buddy here.
You really get the most.best interactive options built-in.

For web-experiments, Inkscape + Firefox => 3.6 (DragDrop) +
http://eazscape.com/eazup is a scratchpad.

MarkT