LOGO inspired graphics lang
Intro
Idea is to have a very simple language which is able to create line graphics.
- Commands are single letter
- Parameters are single integers
- Language is imperative where each command is executed from first to last
- Language is stateful where current state is important for execution following commands
- Scale of output is adapted so that total image fits within view
- Drawing always start at origo with direction along x axis (0 degrees)
- Comments are started by
#
- Reserved keywords are
M,T,S,C,W,D,N,F,H,R
and symbols#,(,)
Language
Movement
Mx = (m)ove by distance x
Tx = (t)urn by x degrees (values < 180 is left turn)
Pen state
Px = set (p)en color to x
Fx = set (f)ill color to x
Wx = set pen (w)idth to x
Sx = (s)cale by x percent
Draw
Lx = draw line by distance x
Cx = draw circle with radius x
Flow control
Nx() = repeat expression
Gx() = define group identified by x
Gx = call group identified by x
H = halt execution here
R = return to origo at 0 angle and reset pen state
Comments
# = comment line
#() = inline comment
Example
Flower
N8(L50 T40 L50 T140 L50 T40 L50 T185)
Program format
Commands is formatted as one of 3 classes
Single letter like:
H
R
Single letter plus one integer argument like
M123
T45
Single letter plus one integer argument plus one expression argument like
N4(L10T90)
Commands are entered in a sequence with optional space and/or comments between them.
This example
N8(
# flower leaf
L50T20
L50T140
L50T20
L50
# set new direction to 45
T185
)
is equivalent with this
N8(L50 T40 L50 T140 L50 T40 L50 T185)
which looks like this:
Editor
- Web based
- New creates a new drawing with unique link which is saved on backend