2
0
Fork
You've already forked techtree
0
forked from librecast/techtree
A tool to generate an SVG node-map, computer-game style technology tree etc. from a file of nodes and dependencies.
  • C 61.5%
  • Yacc 16.8%
  • CSS 10.2%
  • Lex 7.3%
  • Makefile 4.2%
2023年12月28日 13:55:42 +01:00
.gitignore initial commit 2023年12月27日 22:18:49 +01:00
CODE_OF_CONDUCT.md initial commit 2023年12月27日 22:18:49 +01:00
CONTRIBUTING.md initial commit 2023年12月27日 22:18:49 +01:00
COPYING initial commit 2023年12月27日 22:18:49 +01:00
example.css add examples 2023年12月28日 13:25:59 +01:00
example1.tree add examples 2023年12月28日 13:25:59 +01:00
example2.tree add examples 2023年12月28日 13:25:59 +01:00
grammar.y initial commit 2023年12月27日 22:18:49 +01:00
lexer.l initial commit 2023年12月27日 22:18:49 +01:00
LICENSE.GPL-2.0-only initial commit 2023年12月27日 22:18:49 +01:00
LICENSE.GPL-3.0-only initial commit 2023年12月27日 22:18:49 +01:00
Makefile initial commit 2023年12月27日 22:18:49 +01:00
README.md add note about prerequisites 2023年12月28日 13:55:42 +01:00
techtree.c initial commit 2023年12月27日 22:18:49 +01:00
techtree.css initial commit 2023年12月27日 22:18:49 +01:00
techtree.h initial commit 2023年12月27日 22:18:49 +01:00

techtree

A tool to generate an SVG node-map, computer-game style technology tree etc. from a file of nodes and dependencies.

You can see examples here and here.

https://librecast.net/media/2019-08-078.svg

Usage

techtree [options] < source.tree > output.svg

NB: when embedding the image on a webpage, in order for the SVG to be interactive (for links to work, and for embedded images to load) you need to display the image using an <object> tag, not an <img> tag. This is due to "security reasons", and is not just some dodgy hack by browser developers to ensure the codepath for rendering the image uses the "object" code and not the "img" code. No, really.

eg. <object type="image/svg+xml" class="techtree" data="/media/2019-08-078.svg"></object>

Options

All the following options can also be supplied as globals at the top of the .tree file. Options in the file take precedence over commandline options.

--circle
draw nodes as circles instead of the default rectangles
--edge
set minimum length of edge (lines between nodes)
--desc "description"
set description
--css filename
CSS stylesheet (will be embedded in resulting SVG)
--title "title"
set title
--top
set top of first node (in pixels)
--height
set height of SVG
--width
set width of SVG

Input File Format

# Lines beginning with a '#' are comments, which are ignored

Global Options

Global options should be placed at the beginning of the input file, before any node definitions.

border
draw a border around the SVG. This will be a rectangle with CSS class "outer"
css "example.css"
embed the CSS from example.css into the SVG
title "Librecast LIVE - NGI0 Discovery Tech Tree"
set a title
desc "NGI0 Discovery Technology Tree for the Librecast LIVE Project"
set a description
edge 150
edge - set the default spacing between nodes (horizontal and vertical)
top 300
top - set top of first node (in pixels)
height 2500
set height of SVG (affects node spacing)
width 2750
set width of SVG (affects node spacing)
maxwidth 2500
set maximum width of SVG (does NOT affect node spacing)

Nodes

Nodes with no dependencies ("requires") will be plotted first in the order in which they appear. The next level of nodes will consist of nodes whose dependencies are all "unlocked" on a previous level. This continues until all nodes are plotted.

Nodes with dependencies will have an edge (line) plotted back to each of those dependencies. No sorting or automatic spacing is done to try and prevent edges from crossing through nodes. To achieve a nice layout, it may be necessary to change the order of the nodes in the source file for a level, or to adjust the positioning of nodes using the 'x' and 'y' directives.

A simple node looks like this:

node {
 name: "Pottery"
}

Nodes require either a "name" or an "image" directive. All other directives are optional.

name: "name of node"
the name of the node. This will be displayed on text nodes, and is used with the "requires" directive to specify parent nodes.
image: "file/url"
an image to display, instead of text. Can be a local path or URI. Needs to be findable by your SVG viewer at the time of rendering.
alt: "Alternate Text for Screen Readers etc."
please test with a screen reader like orca to make sure your SVG is accessible.
class: "cssclass1 cssclass2"
CSS classes to apply to this node
link: "https://example.com/"
the text/image will be xlinked to this URI
desc: "description"
a description. Presently ignored.
requires: "name1", "name2"
a comma-separated list of double-quoted names of parent nodes.
height: NUMBER
set an explicit height for the node
width: NUMBER
set an explicit width for the node
x: [+/-] NUMBER
adjust the x coordinate of the node. Either an absolute number, or can be relative by prepending +/-
y: [+/-] NUMBER
adjust the y coordinate of the node. Either an absolute number, or can be relative by prepending +/-

Limits / Defaults

This was a quick hack. There are some hard-coded limits in techtree.h:

  • maximum number of levels (128)
  • maximum number of nodes (512)
  • maximum number of prerequisites for a single node (16)
  • default height/width of node (150/150)
  • maximum number of chars per node text line (10) (lines longer than this will be automatically wrapped
  • Node text height (16)

Adjust this to suit your needs.

Installation

Requires flex + bison.

make
make install # as root

License

GPLv2 or (at your option) GPLv3

Author

Brett Sheffield bacs@librecast.net