An interactive interpreter for the Logo turtle graphics language. Automatic monitor support, subroutines implemented with "to" and variables with "let."
Dunno what logo is? Wikipedia can explain.
Adapts to whatever the screen size is; uses 4 lines of the computer console for displaying the command center, but automatically detects an attached monitor and duplicates drawing there without the command center. Big monitors recommended, as the tiny dimensions of the computer's screen won't let you see very much.
Current Logo commands/operators:
Spoiler
Implemented commandsforward <dist> / fd <dist> - moves turtle forward <dist> units
left <angle> / lt <angle> - turns left <angle> degrees
right <angle> / rt <angle> - turns right <angle> degrees
penup / pu - picks the pen up, so movement won't draw
pendown / pd - puts the pen down so movement draws
penchar <char> / pc <char> - sets the character drawn by the pen
clean - erases the current drawing
home - returns the turtle to 0,0 angle 0
wait <time> - pauses execution for <time> seconds
repeat <count> [instructions…]
let [name1 value1 name2 value2 … nameN valueN] - for variable assignment
Implemented Operators:
sum <a> <b> - addition
dif </b></a><b><a> <b> - subtraction
mul </b></a><b><a> <b> - multiplication
div </b></a><b><a> <b> - division
sqrt <val> returns square root of <val>
type "quit" to exit the interpreter.
A sample program:
to spiral :startDist :distStep :angleStep :count
let [d :startDist]
repeat :count [fd :D/>/> rt :angleStep let [d sum :)/>/> :diststep]]
end
spiral 1 .1 15 300
and here's a screenshot of the output of that program to an 8x6 monitor with setFontScale(.5)
Spoiler
Video of it in action, using the freshly-implemented clear, home, and wait commands to do animation!
Hypnotic Spirals
Planned features:
Spoiler
- more logo commands - ex. make, freeze, unfreeze, setposx, setposy,
- user input/output commands
- infix operators - ex, 1+1 instead of sum 1 1
- lists (hard-coded for repeat and let currently)
- if statement and conditional operators
- saved programs
- edit command, to launch an editor to create or edit a saved program
- run command, to load and run a saved program
- ability to run saved programs directly from shell, ex. "logo myLogoProgram"
- Compiler - convert saved logo programs into lua programs
- Multiple turtles - will require rewriting to event-based model, fairly radical overhaul
- full lua integration - lua command to execute lua code in logo programs, and moving logo command interpreter to logo api to allow executing logo commands from lua.
it depends on functions in a separate logo api, which it expects to be called simply logo. The api can be used independently of the logo interpreter program to do turtle-like vector drawing.
Latest versions:
v0.3.2 - http://pastebin.com/8jYYn667
logo interpreter v0.2 - http://pastebin.com/x45p4kbX
Installation note: logo interpreter expects logo API to be named "logo" and either be loaded already or in the current directory.
Version history:
Spoiler
logo apiv0.3.2 - http://pastebin.com/8jYYn667
fixed rather serious bug introduced in 0.3.1 that caused roughly half of lines to incorrectly draw as straight horizontal/vertical lines… :D/>/>
v0.3.1 - http://pastebin.com/i4bCF3aM
replaced rough initial line algorithm with improved version based on bresenham's algorithm
v0.3 - http://pastebin.com/9QPphMV3
added home, clean
v0.2 - http://pastebin.com/RsT0tjzz
added support for multiple displays, drawing to regions of screens
v0.1 -
first version. Had forward(), moveTo(), turn(), turnTo(), penUp, penDown, and the line() function.
logo interpreter
v0.1 - http://pastebin.com/z7WT1wnY
first version, interpreter interface, monitor support, basic turtle commands and operators, repeat, let. Req. logo api v0.2 or later.
v0.2 -http://pastebin.com/x45p4kbX
added home, clean, and "to" command to define custom methods. Req. logo API 0.3 or later.