views:

1288

answers:

6

I am trying to code a flowchart generator for a language using Ruby.

I wanted to know if there were any libraries that I could use to draw various shapes for the various flowchart elements and write out text to those shapes.

I would really prefer not having to write code for drawing basic shapes, if I can help it. If someone could point me to some reference documentation with examples of using that library, it would be great.

Thanks!


@Mike:
Thanks for your pointers and insightful commentary. I appreciate it very much.

+1  A: 

ImageMagick has a Ruby binding called RMagick (sometimes known by other names, depending on the repository). (Link) I haven't used it myself, but I believe it will do what you're looking for. You will need to do some coding, but it's along the lines of

draw.rectangle(x1, y1, x2, y2)
draw.polygon(x1, y1,...,xN, yN)
Nathan Clark
A: 

Yes, thank you fluffybunnyclud. But I think what I really need is some sort of vector drawing library which would allow me to put in text within the elements.

I want the user to be able to drag around flowchart elements and zoom in/out too.

Pascal
fyi : this should be a comment. Plus, could you modify your problem statement to include the fact that you want to drag/zoom? That changes the solution set.
rampion
+1  A: 

It sounds like you're going to be limited mainly by the capabilities of whatever user agent you're building for; if this is a web project, drawing capabilities are going to be dependent on the browser. Since Ruby is running server-side, you would at minimum need some JavaScript to allow dragging/zooming, etc. There's plenty of examples of JavaScript being used for vector drawing (just google "javascript graphics library"), but all require coding, and I haven't seen any library that abstracts this elegantly.

Nathan Clark
+3  A: 

The simple answer is that what you want almost certainly doesn't exist. Sorry!

If you're Windows-based then I'd look for a product in the .NET space, where I expect you'd find something. You're probably going to have to pay real money though. I suppose, if you're brave, you may be able to talk to it using IronRuby.

From a non-MS environment I would be hoping for a Java-based solution. As already mentioned, within the Web world, you're going to be hoping some something JavaScript-based, or probably more likely, something from the Flash (or maybe even Silverlight?) world.

Actually, if you want to stay in Ruby and don't mind some risk, Silverlight might be a way to go - assuming the DLR stuff actually works (no experience here). Ruby - much as I love it - hardly has the most mature GUI structure around it.

Mike Woodhouse
A: 

I am totally sure, but check out cairo bindings for ruby. Pango for text. I am investigating then currently and came across this page.

+2  A: 
rampion