Designed for programmers to outline their logic and thoughts visually, Logos is a powerful diagramming and graphing tool that uses its own language with easy to understand grammar and syntax, so you can generate diagrams and graphs that represent your ideas with ease.
Written entirely from scratch in C, Logos is fast and lightweight. It requires no external libraries or dependencies.
Logos scans and parses the supplied text file and constructs a graph of nodes and edges defined by the user. The graph is then "drawn" by a custom svg library and outputted as an svg file.
- Graph Representation: Automatically generate a visual representation of your logic in the form of graphs and diagrams.
- Custom Language: A simple and easy to understand language for creating your graph/diagram with node representations and edges.
- Customizable Output: Customize the appearance of your diagrams, including background color, node color, and font-size.
To use Logos, you need the following:
- A C compiler (e.g. GCC)
- Basic knowledge of creating and editing text files
Clone the repository to your local machine:
git clone [email protected]:yari-dewalt/logos.git
cd logos
Compile the project:
make
-
Create a Text File:
Write your logic in a text file using the defined syntax and grammar. For example:
{"My Diagram"} A = "Start here" B = "Option 1" C = "Option 2" D = "Option 3" A -> B A -> C A -> D
-
Run the Program:
Provide the text file to Logos:
./logos input.txt [...options]
-
View the Output:
Logos will generate an SVG file representing your logic as a graph. Open the SVG file in a web browser or any compatible viewer to see the visual representation.
The basic syntax for creating a graph/diagram in Logos includes defining nodes and their connections. Here's an outline for creating your own graph:
{ "My Graph Title" }
Node1 = "First Node" // Node (variable) declaration.
Node2 = "Second Node"
Node1 -> Node2 // Edge creation (Node1 points towards Node2)
Node2 <-> Node3 = "Node 3"
/* ^^^
Double edge creation and inline declaration /*
Curly braces '{}' are used to define a title for the graph/diagram and expect a string. This is typically done at the beginning for clarity but can be defined anywhere in the text file or not at all.
{ "My Graph Title" }
Nodes/variables are defined and later referenced by identifiers. They must be assigned to a string or a separate identifier. The first time a node receives an edge, it becomes a child of that node so order matters! Note: The node with the first edge created in the graph becomes the root node.
Node1 = "First Node" Node2 = "Second Node" Node 3 = Node1
- These values can be later changed/redeclared as well.
`->` is used for creating a directional edge (connection) from one node to another.
Node1 -> Node2
`<->` is used for creating a bidirectional edge (connection) between two nodes.
Node1 <-> Node3
Inline declarations allow you to define and connect nodes in a single line. (However, assigning to another identifier is not allowed to keep edge creation clear)
Node2 <-> Node3 = "Node 3"
Chaining assignments and connections is also possible:
A = B = C = "Nodes" A -> B <-> C A -> B = "B Child" <-> C = "C Child"
`//` can be used to comment out an entire line.
// TODO: Add more options
`/*` ... `*/` can be used to comment out multiple lines (upto wherever the closing multi-line quote character is).
/* This is an example of multi-line comments! */
You can customize the appearance of your graphs/diagrams by using optional flags:
- -bgc [color] (--background-color [color]) for background color.
- -nc [color] (--node-color [color]) for node color.
- -ts [color] (--text-size [size]) for text size.
- --help for help information.
- --version to check the program version.
Note: All option values that are valid svg values will work. This means that color names like "white" or hex or rgb values will work. If they aren't valid there will be unexpected results. It is recommended to surround option values with double quotes (examples: "orange", "rgb(30, 30, 30)", "#FFFFFFF", "24"). It should also work without but shells can behave differently (I know sometimes the parentheses without a double quote can cause problems).
Contributions are welcome! Feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Thank you to Mermaid for the inspiration for this project.