Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drawing Library for Ruby

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.

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

like image 221
Pascal Avatar asked Aug 14 '08 14:08

Pascal


Video Answer


1 Answers

Write up your flowchart as a directed or undirected graph in Graphviz. Graphviz has a language, dot that makes it easy to generate graphs. Just generate the dot file, run it through Graphiviz, and you get your image.

graph {
  A -- B -- C;
  B -- D;
  C -- D [constraint=false];
}

renders as
undirected

digraph {
  A [label="start"];
  B [label="eat"];
  C [label="drink"];
  D [label="be merry"];

  A -> B -> C;
  C -> D [constraint=false];
  B -> D [ arrowhead=none, arrowtail=normal]; // reverse this edge
}

renders as
directed

You can control node shapes and much more in Graphviz.

like image 144
rampion Avatar answered Sep 23 '22 15:09

rampion