Update README for JSON inputs

This commit is contained in:
Dimitri Lozeve 2018-01-17 22:36:15 +00:00
parent 3f8d761d8e
commit 217ebcf8f6

View file

@ -15,18 +15,29 @@ This program can be used to generate arbitrary L-systems. It supports:
+ personalized angle and segment length for the representation + personalized angle and segment length for the representation
+ push ('[') and pop (']') operations + push ('[') and pop (']') operations
** ~LSystem~ data type ** L-systems
An L-system consists of: *** ~LSystem~ data type
+ the L-system itself:
An L-system consists of:
+ the L-system itself:
+ an alphabet + an alphabet
+ an axiom (i.e. the starting point) + an axiom (i.e. the starting point)
+ a set of rewriting rules (represented as a list of tuples) + a set of rewriting rules (represented as a list of tuples)
+ rules to transform it into a graphical representation: + rules to transform it into a graphical representation:
+ an angle and a length + an angle and a length
+ a set of representation rules (which symbols mean "draw forward", + a set of representation rules (which symbols mean "draw forward",
"turn left", "pop a position", etc.) "turn left", "pop a position", etc.)
*** JSON format for L-systems
L-systems can be specified using a straightforward JSON encoding. See
the =examples/= folder for examples.
Note that the ~rules~ and ~representation~ keys are associated to
arrays of arrays in JSON. ~angle~ and ~distance~ are
numbers. Everything else should be a string.
** Building and running ** Building and running
You will need [[https://docs.haskellstack.org/][Stack]]. You will need [[https://docs.haskellstack.org/][Stack]].
@ -34,7 +45,7 @@ You will need [[https://docs.haskellstack.org/][Stack]].
From the repository, run: From the repository, run:
#+BEGIN_SRC sh #+BEGIN_SRC sh
stack build stack build
stack exec lsystems-exe stack exec lsystems-exe -- examples/penroseP3.json
#+END_SRC #+END_SRC
This will open a window, where you can move around using the mouse and This will open a window, where you can move around using the mouse and
@ -51,22 +62,22 @@ command-line arguments, see the output of ~--help~:
#+BEGIN_SRC #+BEGIN_SRC
lsystems -- Generate L-systems lsystems -- Generate L-systems
Usage: lsystems-exe [LSYSTEM] [-n|--iterations N] [-c|--color R,G,B] Usage: lsystems-exe FILENAME [-n|--iterations N] [-c|--color R,G,B]
[-w|--white-background] [-l|--list-lsystems] [-w|--white-background]
Generate and draw an L-system Generate and draw an L-system
Available options: Available options:
LSYSTEM L-system to generate (default: penroseP3) FILENAME JSON file specifying an L-system
-n,--iterations N Number of iterations (default: 5) -n,--iterations N Number of iterations (default: 5)
-c,--color R,G,B Foreground color RGBA -c,--color R,G,B Foreground color RGBA
(0-255) (default: RGBA 1.0 1.0 1.0 1.0) (0-255) (default: RGBA 1.0 1.0 1.0 1.0)
-w,--white-background Use a white background -w,--white-background Use a white background
-l,--list-lsystems List all available L-systems
-h,--help Show this help text -h,--help Show this help text
#+END_SRC #+END_SRC
** Examples
** Examples provided Examples are provided in the =examples/= directory.
*** Space-filling curves *** Space-filling curves