Skip to content

yari-dewalt/logos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logos

About

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.

How it works

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.

Features

  • 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.

Getting Started

Prerequisites

To use Logos, you need the following:

  • A C compiler (e.g. GCC)
  • Basic knowledge of creating and editing text files

Installation

Clone the repository to your local machine:

git clone git@github.com:yari-dewalt/logos.git cd logos

Compile the project:

make

Usage

  1. 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
  2. Run the Program:

    Provide the text file to Logos:

    ./logos input.txt [...options]
  3. 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.

Syntax and Grammar

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 /*

Title Definition

  • 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" }

Node/Variable Declaration

  • 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.

Edge Creation

  • `->` 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 and Chaining

  • 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"
  • Comments

  • `//` 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! */

Customization

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).

Contribution

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

Thank you to Mermaid for the inspiration for this project.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published