Vector graphics library with pan and zoom

Hello,
I’m not trying to open a debate about which GUI library is the best.
I would just like a pointer to a graphics library I can use to draw
some vector graphics (lines, arcs, circles, polygons, possibly filled
polygons, etc…) which would be presented to a Windows user in a
window which (s)he could pan and zoom in and out.

Does anybody know if such a beast exists?

If not, can anybody point me at the easiest way to get something close
to that?

If not, can anybody point me at the easiest way to get any sort of
vector graphics drawn in a Windows window? (This is the part I cringe
at – I’m really not trying to ignite a holy war here.)

Thanks for any pointers…

–wpd

Patrick D. wrote:

If not, can anybody point me at the easiest way to get any sort of
vector graphics drawn in a Windows window? (This is the part I cringe
at – I’m really not trying to ignite a holy war here.)

Thanks for any pointers…

–wpd

TkCanvas is very good for that.

You can use it as a library, but what I’ve found useful recently is to
isolate the vector drawing and user interaction (select, drag, drop,
pan, zoom) in a separate process. This permits using it from simulink,
for example.

http://path.berkeley.edu/~vjoel/vis/tkar/

There’s a protocol for talking to tkar, documented in the above.

Thanks.
I’ll take a look at that.

It’s funny you should mention simulink – I meant to add to my
original post that I was hoping to find something that provided
similar capabilities (zoom, aspect ratio control, and auto scale, in
particular) as are provided by the plotting capabilities of MATLAB.

Basically, I would like to plot some shapes I’ve drawn in a Ruby
program and to be able to zoom in and out to see more or less detail.
My current “simplest, because I know exactly how to do it, but
stupidly complex” plan is to dump the data to a file which I would
read and plot from a MATLAB script.

I’m hoping to find a more elegant solution than that, and to add that
capability to my bag o’ tricks.

I’ll try talking to your Tkar process. I don’t need the animation
capabilities you provide, but if I can draw my lines, arcs, and
polygons, and I can zoom in and out of the drawn figure, then I can
check this box off and move on to the next problem.

–wpd

Dear Patrick,

scalable vector graphics can be created using the Processing language :

http://processing.org/

There are Ruby bindings for it by _why:

http://the-shoebox.org/apps/44
Thank you. I’ll take a look at that.

Also, you might like RMagick:

http://rmagick.rubyforge.org/portfolio3.html
Unfortunately, it appears that RMagick doesn’t appear to be able to
display on a Windows platform. (I could generate the .gif file in the
example fine, but it seemed like it really wanted to talk to an X
server to display something on the screen.)

–wpd

Also, you might like RMagick:

http://rmagick.rubyforge.org/portfolio3.html
Unfortunately, it appears that RMagick doesn’t appear to be able to
display on a Windows platform. (I could generate the .gif file in the
example fine, but it seemed like it really wanted to talk to an X
server to display something on the screen.)

–wpd

Dear Patrick,

you’re right. Tim H., the developer of RMagick, says so
somewhere…
I’m using Linux mostly, so I tend to forget about Windows specificities.
However, you might be able
to combine a gif created by RMagick with a display software on Windows,
even though that’s less elegant …

Best regards,

Axel

-------- Original-Nachricht --------

Datum: Sat, 16 Aug 2008 06:54:15 +0900
Von: “Axel E.” [email protected]
An: [email protected]
Betreff: Re: vector graphics library with pan and zoom

–wpd

Dear Patrick,

you’re right. Tim H., the developer of RMagick, says so somewhere…
I’m using Linux mostly, so I tend to forget about Windows specificities.
However, you might be able
to combine a gif created by RMagick with a display software on Windows,
even though that’s less elegant …

This could be a solution that works on Windows together with RMagick:

http://cairographics.org/
http://cairographics.org/rcairo/

Best regards,

Axel

-------- Original-Nachricht --------

Datum: Fri, 15 Aug 2008 21:01:02 +0900
Von: “Patrick D.” [email protected]
An: [email protected]
Betreff: Re: vector graphics library with pan and zoom

My current "simplest, because I know exactly how to do it, but

–wpd

Dear Patrick,

scalable vector graphics can be created using the Processing language :

http://processing.org/

There are Ruby bindings for it by _why:

http://the-shoebox.org/apps/44

Also, you might like RMagick:

http://rmagick.rubyforge.org/portfolio3.html

Best regards,

Axel

Patrick D. wrote:

It’s funny you should mention simulink – I meant to add to my
original post that I was hoping to find something that provided
similar capabilities (zoom, aspect ratio control, and auto scale, in
particular) as are provided by the plotting capabilities of MATLAB.

I’ve never tried using it directly from MATLAB, as opposed to simulink.
The simulink dir (http://path.berkeley.edu/~vjoel/vis/tkar/simulink/)
contains a zip of the files that build the simulink block, including
tkar.c which starts the external process and translates simulink port
data to winsock socket comm. (Yeah, windows–this was used as part of a
project for general motors, which is slowly discovering linux). This
file builds with the MATLAB mex compiler, and it might be a starting
point to adapt it as a matlab extension.

Patrick D. wrote:

If not, can anybody point me at the easiest way to get any sort of
vector graphics drawn in a Windows window? (This is the part I cringe
at – I’m really not trying to ignite a holy war here.)

Batik in JRuby?

  • Charlie

Hi Joel,
Thanks for the tip. However, I’m not planning on interfacing Tkar to
MATLAB, I just mentioned MATLAB because I am quite enamoured of the
visualization capabilities provided by the “plot” command in MATLAB,
and was hoping to find something of a similar nature I could access
from a Ruby script. Thus far, I have found (or, more accurately, been
shown – by you) Tkar, which provides the pan and zoom capability I
desire. I have also found rgplot, which provides an interface to
gnuplot.

For the ridiculously large amount of data I want to plot, I have found
TKar to be too slow for my needs (taking 20 minutes to plot a single
data set). gnuplot can handle that amount of data easily, but the
pipe between ruby and gnuplot seems to overflow as the data are
written. (I found a description very similar to the problem I have
observed on an Octave mailing list. Unfortunately, I have misplaced
that page at the moment).

So, right now I am looking at 4 options:

  1. Read through your Tkar code enough to extract out the code that
    plots lines and arcs on a zoomable, pan-able canvas and integrate that
    with my code.

  2. Find that darn web page again, verify that Ruby has the same issue
    as Octave and, hopefully, can be fixed by the same patch proposed, and
    submit a patch against Ruby to fix that.

  3. Give up on plotting altogether.

  4. Dump my data to a file readable and plottable by MATLAB and use
    MATLAB to visualize my data.

–wpd

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs