Flush is a script language for drawing procedural vector graphics. It was developed as the graphic engine of the RTS game "Palito", but may be useful in other projects.
The language is quite simple, it has just added the features I needed. Fell free to send questions and/or feedback to the author: barrett@9hells.org
LEXICAL:
Flush tokens are separated by any white space (space, tab, newline). ``#'' start a comment, that extends to the end of the line. Block (possibly multi-line) comments are delimited by ``{'' and ``}''.
VARIABLES:
There is currently just only one type of variable, that holds a
floating point number.
Variables does not need to be defined, that's done automatically the first
time a variable appears on the code (usually on a ``='' command).
Variables names must be prefixed by a ``$'' sign.
EXPRESSIONS:
All operations are expressed in Polish Notation, that is: there is no parenthesis, the operator cames first, then the operands. Some examples:
1 + 2 >>> + 1 2 (4 + 5) * 6 >>> * + 4 5 6
$x = sin($t)/3 >>> = $x / sin $t 3
OPERATORS:
- $var <value>
--attribution
+ - * /
--basic math
== != < > <= >=
--comparision
and or not
--boolean logic
exp pow sqr sqrt log
sin cos tan asin acos atan atan2 % abs
--math
fold fold2
time msec rand01
rand01 # random number between 0 and 1
rad <angle>
--convert an angle in degrees to radian
2pi pi pi2 pi4 pi6 pi12
--PI and multiples
FLOW CONTROL:
(note: ``[...]'' means a block of flush code)
if <condition> [...] end
if <condition> [...] else [...] end
function <function-name> [...] end
return
call <function-name>
callif <function-name> <condition>
for $var <start> <end> <step> [...] end
for $var = <start> to <end> step <step> [...] end
break
breakif <condition>
label <label-name>
goto <label-name>
COMMANDS:
line <x0> <y0> <x1> <y1>
circle <x> <y> <radius>
semicircle <x> <y> <radius0> <radius1>
--absolute drawing (coordinates indicate pixels on screen)
color <24bit color>
rgb <red> <green> <blue>
alpha <alpha>
hollow <bool> # force hollow shapes (do not fill)
--set drawing parameters
point2d <x> <y>
line2d <x0> <y0> <x1> <y1>
polyline <x0> <y0> [ ... <xn> <yn> ] [ end | close ]
circle2d <x> <y> <radius>
fillcircle <x> <y> <radius>
dashline2d <x0> <y0> <x1> <y1> <offset> <dash count>
--2D drawing (affected by 2d transforms)
push
pop
translate <x> <y>
rotate <angle>
scale <scale x> <scale y>
--2D transform
write $var
read $var
--debug functions (write and read variables from console)
