Tempath is a template language for path data, which is the superset of SVG Path Data syntax. Inspired by Prototypo's under the hood part.
npm install -g tempath
$ tempath --help
Usage: tempath <file> [argument]... [options]
file path template file
argument number values that be used to path property
Options:
-h, --help print this message
$ echo "prop \$a, \$b, \$c, \$d M 0 0 L \$a+\$b \$c*\$d 6 0 Z" > sample.path
$ cat sample.path
prop $a, $b, $c, $d M 0 0 L $a+$b $c*$d 6 0 Z
$ tempath sample.path 1 2 3 4
M0,0L3,12L6,0Z
Since tempath is the superset of SVG path data, you can use all feature of it.
M 0,0 # also you can use comment!
L 1,2 3,4 # command letter can be eliminated on same subsequent commands
c 5,6 7,8 9,10 # relative versions of all commands are available
Tempath code is a list of commands. You can also define your custom command with other commands.
set
: set the variableprop
: define property that represent the pathdef
: define custom commandif
: conditional execution of commandfor
: make loopimport
: import foreign template on command
Variable name starts with $
character.
set $a, 1
set $b, 2
M $a $b # M1,2
prop
command takes a value from outside, and set the value to variable.
prop $a # Take one value from outside, just set $a by that.
prop $b 0~1 # Take one value from outside,
# but limit the value into 1~2(inclusive).
prop $c 2 # If there is no value outside, set 2 to $c.
prop $d 3~4 5 # Default value also limited.
# thus, set 4 when default is used
set $a, 1 + 2 * 3 # set $a to 7
set $b, 1 < 2 # set $b to 1(true)
set $c, 1 = 2 # set $c to 0(false)
set $d, not 1 = 2 # set $d to 1
+
-
*
/
%
<
>
<=
>=
=
Call the function as s-expr style.
set $a, (cos (sin 0)) # set $a to 1
ceil
round
floor
sin
cos
tan
sqrt
atan2
use mocha for generate parser code & test.
$ npm install -g mocha
$ mocha
Distributed under MIT License