A very simple Turtle Graphics implementation using HTML5 canvas and JavaScript. Usage instructions are available on the web page (Default.htm). For example, this draws a “galaxy”:
0(1adf89r)180x
Give it a try: http://brieflang.com/turtle/?0(1adf89r)180x
There's also a YouTube demo here: http://www.youtube.com/watch?v=CVFcpoULWq4
It is driven by a tiny stack language allowing single-character commands to move the turtle and draw and do animations. Quotations are used to treat code as data (pushed to the stack); allowing repetition and definition of new commands.
hHome - Reset x,y to 160,160
nNorth - Reset bearing
gGo - Sets x,y from stack10,20g
cClear - Clears canvas (useful for animation)
fForward - Draws forward n pixels10f
mMove - Moves forward n pixels10m
lLeft - Turn bearing left n degrees90l
rRight - Turn bearing right n degrees90r
xRepeat - Repeats quotation n times(100f90r)4x
aAdd - Adds two numbers4,2a
-Subtract - Subtracts two numbers4,2-
*Multiply - Multiplies two numbers4,2*
vDivide - Divides two numbers4,2v
jJoin - Prepends head onto quotation10(f90r)c
uUnjoin - Separates head from tail(10f90r)u
dDup - Duplicates top stack value
wSwap - Swaps top two stack values
oDrop - Discards top stack value
iDip - Applies quote below next value10,20(f)i
Parenthesis surround quotations (100f90r).
Digits [0123456789] build decimal numbers. Commas separate adjacent numbers.
Define unused characters by following quotation. (90r)R defines R as substitution for 90r.
Canvas is 320x320. Turtle begins at 160,160 bearing North.