Movement: (fd distance) - Move forward. (bk distance) - Move backward. Example: (fd 100) ;; Moves the turtle 100 units forward. Rotation: (rt angle) - Turn right. Alias: yaw. (lt angle) - Turn left. (nu angle) - Nose up. Alias: pitch. (nd angle) - Nose down. (rcw angle) - Roll clockwise. (rcc angle) - Roll counter clockwise. Alias: roll. Example: (rt 90) ;; Turns the turtle 90 degrees to the right. Drawing: (cs) - Clear screen. (pu) - Pen up (don't draw when moving). (pd) - Pen down. (setpc r g b a) - Set pen color. Takes red, green, blue and alpha (transparency) as values between 0 and 1. (setpw width) - Set pen width. (setpq quality) - Set pen quality (1 by default). Example: (setpc 1.0 0.5 0 0.5) ;; Change drawing color to translucent orange. Turtle control: (ht) - Hide turtle. (st) - Show turtle. (setxyz x y z) - Move the turtle to a new position. (home) - Move the turtle to home position (0,0,0), and point it up. Looping: (repeat n commands) - Execute commands n times. Example: (repeat 4 (fd 90) (rt 90)) ;; Draws a 90x90 square. Function definition (to name body) - Defines a function with no arguments (to (name arg1 ... argn) body) - Defines a function with named arguments. Example: ;; Define a function called square which take a 'length' argument. (to (square length) (repeat 4 (fd length) (rt 90))) ;; Draw a 120x120 square using the function (square 120) Math: +, -, *, /, max, min - Take two arguments and return the result. Example: (+ 1 2) ;; Returns 3. (inc x) - returns x+1. (dec x) - returns x-1. =, ==, <, >, <=, >= - Predicates, take 2 arguments, return true or false. Example: (= 2 4) ;; Returns false. pos?, neg?, zero? - Predicates, take one argument, return true or false. Conditionals: (if condition then [else]) - Evaluates and tests condition, and depending on the result evaluates either the then or else clause. Example: (if (< 1 2) 'yes 'no) ;; Returns 'yes Advanced: (def name value) - Creates a new global var. (set! name value) - Set an object's value. (new class) - Instanciate a new object. (. target field) - Get a field on a object. (. target (method args...)) - Call a method on an object. *stage* - The stage object. Example: (new flash.display.Sprite) ;; Returns a new sprite. Another example: (to test (fd 10) (rt 10)) ;; Define a function called 'test'. (pu) ;; Don't draw anything! (. *stage* (addEventListener "enterFrame" test)) ;; Call test on every frame. Yet another example (from las3r's wiki): (def p (new flash.display.Sprite)) (def g (. p graphics)) (. g (beginFill 0xFF0000)) (. g (drawRect 0 0 50 50)) (. g (endFill)) (. *stage* (addChild p)) (. *stage* (addEventListener "enterFrame" (fn* [e] (set! (. p x) (+ (. p x) 2))))) Code to generate the tree at startup: (to demo (to (tree size branches depth) (if (> depth 0) (do (setpc (- 1 (/ 0.5 depth)) (/ 1 depth) (+ 0.5 (/ 0.5 depth)) 1) (setpw (/ size 7)) (setpq (* depth 2)) (fd size) (repeat branches (rcc (/ 360 branches)) (nd 50) (tree (* 0.66 size) branches (dec depth)) (nu 50)) (pu) (bk size) (pd)))) (cs) (pu) (bk 150) (pd) (tree 200 3 6) (setpw 1) (setpq 1)) (demo) Credits: This program was made with Las3r and filmed in PaperVision3D. (c) Copyright 2008 Yonatan Offek, No rights reserved.