<p>I am trying to code a flowchart generator for a language using Ruby. </p>

<p>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. </p>

<p>I would really prefer not having to write code for drawing basic shapes, if I can help it. </p>

<p>Can someone could point me to some reference documentation with examples of using that library?</p>

[{'answer_id': 11191, 'author': 'Nathan Clark', 'author_id': 1331, 'author_profile': 'https://Stackoverflow.com/users/1331', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n\n<p>ImageMagick has a Ruby binding called RMagick (sometimes known by other names, depending on the repository). (<a href="http://rmagick.rubyforge.org/" rel="nofollow noreferrer">Link</a>)\nI 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 </p>\n\n<pre><code>draw.rectangle(x1, y1, x2, y2)\ndraw.polygon(x1, y1,...,xN, yN)\n</code></pre>\n'}, {'answer_id': 12120, 'author': 'Mike Woodhouse', 'author_id': 1060, 'author_profile': 'https://Stackoverflow.com/users/1060', 'pm_score': 3, 'selected': True, 'text': '<p>The simple answer is that (at time of writing) what you want almost certainly didn\'t exist. Sorry!</p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>Update: Since writing this (approaching 5 years ago) the situation has improved - a little. While I\'m still not aware of any specific Ruby graph-drawing libraries, there is improved support for <a href="http://www.graphviz.org/" rel="nofollow noreferrer">Graphviz</a> <a href="https://github.com/glejeune/Ruby-Graphviz/" rel="nofollow noreferrer">here (Github</a>) or by <code>gem install ruby-graphviz</code>. I\'ve found that for simple graphs, it\'s quite possible to write the script directly from Ruby.</p>\n'}, {'answer_id': 388361, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>I am totally sure, but check out cairo bindings for ruby. Pango for text. I am investigating then currently and came across this page.</p>\n'}, {'answer_id': 388911, 'author': 'rampion', 'author_id': 9859, 'author_profile': 'https://Stackoverflow.com/users/9859', 'pm_score': 4, 'selected': False, 'text': '<p>Write up your flowchart as a directed or undirected graph in <a href="http://www.graphviz.org/About.php" rel="nofollow noreferrer">Graphviz</a>.  Graphviz has a language, <a href="http://www.graphviz.org/Documentation.php" rel="nofollow noreferrer">dot</a> that makes it easy to generate graphs.  Just generate the dot file, run it through Graphiviz, and you get your image.</p>\n\n<pre><code>graph {\n  A -- B -- C;\n  B -- D;\n  C -- D [constraint=false];\n}\n</code></pre>\n\n<p>renders as <br>\n<a href="http://www.flickr.com/photos/rampion/3130993214/" rel="nofollow noreferrer" title="undirected by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3126/3130993214_af71aa44f6.jpg" width="183" height="255" alt="undirected" /></a></p>\n\n<pre><code>digraph {\n  A [label="start"];\n  B [label="eat"];\n  C [label="drink"];\n  D [label="be merry"];\n\n  A -&gt; B -&gt; C;\n  C -&gt; D [constraint=false];\n  B -&gt; D [ arrowhead=none, arrowtail=normal]; // reverse this edge\n}\n</code></pre>\n\n<p>renders as<br>\n<a href="http://www.flickr.com/photos/rampion/3130162313/" rel="nofollow noreferrer" title="directed by rampion, on Flickr"><img src="https://farm4.static.flickr.com/3085/3130162313_51e5b00dc9.jpg" width="212" height="255" alt="directed" /></a></p>\n\n<p>You can control node shapes and much more in Graphviz.  </p>\n'}]
['https://Stackoverflow.com/questions/11145', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1311/']