george.application.turtle.turtle

George Turtle Geometry implements only the basic (procedural) single-turtle  functions of the original UCB Logo TG, not (for now) the obect-oriented multi-turtle environment of Python.

Furthermore, certain changes have been made to some of the function-names to make them more consistent, readable, an 'clojure-y' - mainly inserting hifens in multy-word function names.

We use 'standard' mode for TG as this is most in line with underlying standard math:
1. Turtle home is origo.
2. Origo is center of screen.
3. X increases to the right, Y increases upwards.
4. Degrees are counter-clocwise. 0 degrees is facing right.

    

-main

(-main & _)

CB

clear

(clear)
Removes all graphics from screen.

Ex.: (clear)

data

DEFAULT_SCREEN_SIZE

forward

(forward distance)
Tutle command.
Moves the turtle forward 'distance' in the direction the turtle is heading.
Negative number also possible, which results in the turtle moving backward.

Ex.: (forward 50)

heading

(heading)
Turtle command.
Returns the current heading (angle) of the turtle relative to positive X axis, rotation counter-clockwise.
The returned number will be a positive number from 0 to 359.

Ex.: (heading)

hide

(hide)
Turtle command.

Ex.: (hide)

home

(home)
Turtle command.
Moves the turte back to the center of the screen.
Makes the turtle visible, heading 0, postion [0 0], pen-down.

Ex.: (home)

is-pen-down

(is-pen-down)
Pen command.
Returns 'true' or 'false'.

Ex.: (is-pen-down)

is-showing

(is-showing)
Turtle command.
Returns 'true' or 'false'.

Ex.: (is-showing)

left

(left degrees)
Turtle command.
Rotates the turtle counter-clockwise from current heading.
Negative number also possible, which will result in a clockwise rotation.

Ex.: (left 90)

ordered-command-list

pen-color

(pen-color)
Pen command.
Returns a string representing a "web color", or a JavaFX Color instance,
e.g. "black" or "#ff0000" (red) or
  Color/CORNFLOWERBLUE or (Color/color 0 255 0 0).

Ex.: (pen-color)

For more on JavaFX Color, see:
http://docs.oracle.com/javase/8/javafx/api/javafx/scene/paint/Color.html

pen-down

(pen-down)
Pen command.
Sets down the pen, so when the turtle moves, a line will be drawn.

Ex.: (pen-down)

pen-up

(pen-up)
Pen command.
Picks up the pen, so when the turtle moves, no line will be drawn.

Ex.: (pen-up)

position

(position)
Turtle command.
Returns the current position (coordinates) of the turtle relative to 'origo' (center of screen.) 'x' is right, 'y' is up.

The value is a 2-item vector: [x y]
The vector can be desctructed, or 'first' or 'second' can be called on it to get just the x or y value.

Ex.:
(position)
(let [p (position)] ...)
(let [[x y] (position)] ...) ;; destructing
(let [x (first (position))] ...)

rep

macro

(rep n & body)
Utility command.
Repeatedly executes body (presumably for side-effects) from 0 through n-1.

Ex.:
(rep 3
     (forward 50) (left 120))

reset

(reset)
Combined screen and turtle command.
Clears the screen, and center the current turtle, leaving only one turtle.
Same as calling `(clear) (home)`

Ex.: (reset)

right

(right degrees)
Turtle command.
Does the same as as 'left', but in opposite direction.

run-sample

(run-sample)
A test program which uses most of the avilable turtle commands.

screen

(screen)(screen width height)
same as 'turtle', but with possibility to create different sized screen.

screenshot-filechooser

SCREENSHOT_BASE_FILENAME

set-heading

(set-heading degrees)
Turtle command.
Rotates the turtle to the given heading.  See 'heading'.

Ex.: (set-heading 90)

set-pen-color

(set-pen-color color)
Pen command.
Sets the pen to the specified web color (String) or JavaFX Color.
See: 'pen-color'

set-position

(set-position [x y])
Turtle command.
Moves the turtle to the given position.  (See 'position').
If x or y are "falsy" (i.e. 'nil' or 'false'), then that part is ignored.

Ex.:
(set-position [30 40])
(set-position [30 nil]) ;; y is changed, only x

show

(show)
Turtle command.
Makes the turtle visible.

Ex. (show)

sleep

(sleep milliseconds)
Utility command.
Causes the thread to "sleep" for the number of milliseconds.
1 second = 1000 milliseconds

Ex.: (wait 2000)  ;; sleep for 2 seconds

square

(square)

turtle

(turtle)
get-or-create a screen (with default size) and a turtle.
Returns turtle instance