Your browser doesn't support the HTML5 canvas. Please upgrade to a more recent web browswer.
Guide | Reference | Library
Welcome to Logo Lite a small turtle graphics interpreter Quick Start =========== Click the 'Library' tab and select a program. The code will copy into the editor. Use the 'Run' button, or keyboard ‹shift› ‹return› to run code in the editor. You can change the turtle speed while it is drawing. If you are building up a program one step at a time, then start with CS (ClearScreen). Enter short one line commands in the lower command line. Use the 'Go' button, or keyboard ‹return› to run code in the command line. If no entry is made, ‹return› will recall the previous entry. Use the 'Stop' button to stop the turtle. The print screen overlays the graphics screen. Print text can be copied but not edited. The turtle and print text are always white. Use the 'swop' button to swop between two editor code areas. Useful to try out changes or another program. Use the 'form' button to expand or contract common double letter shortforms. rsa, cs, ct, fd, bk, rt, lt, pu, pd, ar, al, st, ht, pr, op, bf, bl, se and SS. Also removes any lines starting with '>'. This allows you to copy and paste print output text into the editor. The graphics screen is 401 by 401 pixels, from -200 to +200. Home position is central [0 0]. If the turtle moves outside the screen, the border turns grey. Some 'static turtle' commands draw without turtle movement so do not trigger a border change. Use the 'grid' button to hide / show a background grid. Info ==== Logo Lite is a single-page web application. All the programs and info are contained in a single page. Save this page to a USB stick to use off line. Only the Web Links won't work. It's easier to enter commands with spell checkers and auto completers turned off. On an iPad go to 'General' then 'Keyboard' settings menu. Save your eyesight and zoom into the screen. With Mac OS use Ctrl key and mouse scroll wheel. If you need to hide the print text, use Repeat 20 [Print []], and scroll down. Logo Programming ================ Logo Lite uses space separated words and lists. Words are case insensitive, so "a = "A. Words can only contain letters (a-z), numbers (0-9) and underscore (_). There are 4 types of word: 1/ Strings: words with a prefix " (quote) character. eg. "Area88 is a string of 6 characters. Only the initial quote is needed. Hence " is an empty string - a string with zero characters. 2/ Numbers: words containing only digits (0-9) and an optional decimal point. Numbers must begin and end with a digit. eg. 123.45 Numbers preceded by a space (or '(' or '[') and minus character are negative. eg. -23.5. 3/ Booleans: words 'true' and 'false'. (Cannot use '1' and '0'). 4/ Lists, which contain a series of 'things' (words or lists) between square brackets [ ]. eg. ["Dave :age ["coins 5] false] is a list of 4 things. [] is an empty list - a list with zero things. Words with a prefix : (colon) character are variables. eg. :size Variables allow a value to be stored as a variable name. Values are things or other variables. Valid variable names (called symbols) must start with a letter. When evaluated, the symbol is replaced with its stored value. Otherwise, words are treated as procedure names. Procedures are a set of commands, either built-in (primative) or user defined. There are 2 types: Commands carry out actions (eg. PenUp) Operations output some value (always a thing), (eg. Sum 3 4 outputs 7). to name ip1 ip2... commands end Where 'name' is the procedure name and 'ip1 ip2...' are input things. Valid procedure names must start with a letter. eg. "Name, "size_A4 but not "3rd. Procedures have dynamic scope, so sub procedures can use parent values. Variables and procedures always evaluate to things, so are not additional data types. Control Variables ================= Here are two common control variables, often used in recursive loops. :pm1 either plus or minus 1. Invert with Minus :pm1 :tf either true or false. Invert with Not :tf Outputs ======= These commands output 'null': any turtle drawing command. First, Last or Pick an empty string or list. These commands are lost, simply disappear. empty parenthesis (). More than one item within parenthesis. eg. Print (8 11)/4 outputs 2, the 11 is lost. Parenthesis must evaluate to a single value. Extra items within a list. eg. SetPos [0 0 44] moves the turtle to the home position, the 44 is lost. Abbreviations ============= Error messages and command reference may use the following abbreviations: wrd - word (string, number or boolean) str - string sym - symbol (valid string, starts with a letter) chr - character (single a-z, 0-9 or underscore) num - number int - integer t/f - boolean (true / false) thg - thing (word or list) lst - list ind - index (place in string or list, 1-Count) +ve - positive At the moment, error messages reload the parser, which clears all memories. Any code in the Editor is not cleared, allowing the Run button to reload procedures / variables back into memory. Differences =========== The main differences between Logo Lite and more traditional Logo versions are: 1/ Strings must be quoted to prevent evaluation, even inside lists. Otherwise interpreted as a procedure. eg. Show ["rgb "blue "is blue] outputs rgb blue is [0 0 99] and Make "a [Forward 44] will move the turtle forward 44 and make "a an empty list. 2/ Input data types. eg. First 77 throws an error. Use Word " 77 (with empty string) to convert to a string. Likewise, with Sqrt "16 use Integer "16 to convert to a number. Floating point or negative numbers cannot be quoted as the decimal point and '-' characters cannot be contained in a string. Note that single characters can be converted between number and string with Ascii or Char. Useful for printing punctuation characters 'on the fly'. 3/ All procedures have a fixed number of inputs. So Pr (Sum 3 4 5) outputs 7 and loses the 5. 3/ Comments use # character. 4/ SetPenWidth not SetPenSize. Limited to 99 pixels. 5/ Wipe instead of Clean (too similar to Clear). 6/ Filled color declared separately with SetFillColor. 7/ Some 'missing' procedures: SetXY - use SetPos [x y], as lists are evaluated. (Sum 1 2 3) - use 1 + 2 + 3. (List :r) - use [:r], as lists are evaluated. Arc d r - use FD r RT 90 ArcR d r LT 90 BK r LT d. PenErase - unavailable, maybe set pen to background color. PenReverse - effect unavailable. Beforep - use Lessp. Forever - use a large number. Known Issues ============ 1/ Using a value or procedure before it has been described. The program code is read from the top as normal, so values and procedures need to be described first, before they are used. Logo Lite saves previous values and procedures. An error message will clear all values and procedures. Deleting from the editor does not delete from memory. Use PrintOutAll to see memory contents. Clear memories with ResetAll command. 2/ Nested repeat loops do not always reinstate RepCount correctly. Use For loops instead. 3/ All errors reload Logo Lite, which clears the memory. Run code again to reload memories. Web Links ========= Comments to Back to cr31 Main Menu Right click to open Reference and Guide pages in a new tab. Logo Lite commands are based on Berkeley Logo Commands Reference.
Logo Lite Command Reference: ============================ Commands: Forward FD BacK Operations: Sum 3 4 Strings: "foo "bar Numbers: 0, 0.1, 20 Booleans: true false Lists: [1 2 [3 4] 5] Variables: :foo :bar Procedures: Name ip1 ip2... Names: are case insensitive, so NoName = noNAME. use letters a-z, numerals 0-9 and _ (underscore). must begin with a letter. Comments: text after a '#' is ignored. =================== Commands Reference: =================== Screen: ======= Logo begins with a black background and a white pen. ClearScreen Clear graphics screen and place turtle at center with heading 0. CS Same as Home Wipe. Wipe Clear graphics screen. Turtle unchanged. SetBackGround Set background color, name / [rr gg bb] / n (0-15). Default is black. SetBG See SetPenColor for more info on setting colors. Print text and turtle sprite are always white, so best to keep background colors dark. ClearText Clear printed text (not label text). CT ShowTurtle Make turtle visible. ST HideTurtle Make turtle invisible. HT Note: screen border will not indicate if turtle is outside the screen. ResetAll Reset to default values. Note: does not ClearScreen or ClearText. RSA Only needs to be used at the start of a distributed program to ensure consistency. Pen up, color white, width 2 and ShowTurtle. Background color set to black. Fill transparency 50 and fill color white (will appear grey on a black background). Erase user defined varibles and procedures. Turtle Motion: ============== Forward n Move turtle forward n pixels. FD n Back n Move turtle back n pixels. BK n Same as Forward -n. Right d Turn turtle right (clockwise) by angle d degrees. RT d Left d Turn turtle left (counterclockwise) by angle d degrees. LT d Same as Right -d. PenUp Raise pen. Turtle will not draw a line as it moves. PU PenDown Lower pen. Turtle will draw a line as it moves. PD SetHeading h Turn turtle to heading h degrees, measured clockwise from North. SetH h SetX x Move turtle horizontally to coordinate x. SetY y Move turtle vertically to coordinate y. SetPos [x y] Move turtle to coordinate position [x y]. SetPenWidth w Set pen width (thickness) to w. Must be positive. Minimum width 1. SetPW w ArcRight d r Move turtle through a right hand arc of angle d degrees and radius r. ArcR d r If r is 0 then same as Right d. If r is negative then same as ArcLeft d r. ArcLeft d r Move turtle through a left hand arc of angle d degrees and radius r. ArcL d r If r is 0 then same as Left d. If r is negative then same as ArcRight d r. Home Move turtle to center of screen with heading 0. Same as SetPos [0 0] SetH 0. Turtle Static: ============== can be drawn with pen up or down. Circle r Draw a circle of radius r at the turtles position. r must be positive. Same as FD r RT 90 PD ArcR 360 r PU LT 90 BK r. Can be drawn or filled with the pen up. Dot Draw a round dot with pen color and pen width. Sqot Draw a square dot with pen color and pen width. Plot [x y] Draw a round dot at coordinate [x y] with pen color and pen width. Pen Color: ========== There are 3 alternative formats for setting PenColor. Also used for SetBackGround, SetFillColor, Light and Dark. 1/ name 2/ list of [rr gg bb] 3/ number (0-15) Equal Density Colors Black Output [00 00 00] 0 [30 30 30] 8 Blue Output [00 00 99] 1 Orange [99 50 00] 9 Green Output [00 99 00] 2 [15 65 10] 10 Cyan Output [00 99 99] 3 [00 40 70] 11 Red Output [99 00 00] 4 [80 05 05] 12 Magenta Output [99 00 99] 5 Purple [60 30 80] 13 Yellow Output [99 99 00] 6 [70 70 05] 14 White Output [99 99 99] 7 [65 65 65] 15 Grey Output [50 50 50] SetPC name Set pen color to color name. Black, Blue, Green, Cyan, Red, Magenta, Yellow and White. Also Orange, Purple and Grey. You can always define your own color names: eg. to colorname output [rr gg bb] end SetPenColor [rr gg bb] Set pen color to rgb component values, (0-99). Auto clipped. SetPC [rr gg bb] SetPC n Set pen color to color number n, (0-7), or equal density colors (8-15). Use 1+n%7 to avoid Black, or 8+n%7 to avoid last equal density color. Light Output rgb color 50% lighter, eg. SetPC Light Red. Same 3 input formats as SetPenColor, name / [rr gg bb] / n (0-15). Dark Output rgb color 50% darker, eg. SetPC Dark Green. Same 3 input formats as SetPenColor, name / [rr gg bb] / n (0-15). Hue d Output rgb color depending on angle d degrees, eg SetPC Hue 70. Fills: ====== SetFillTrans n Set transparency of fill to n, from 0 (no transparency) to 99 (fully transparent). SetFT n Default is 50. SetFillColor Set fill color. Same 3 input formats as SetPenColor, name / [rr gg bb] / n (0-15). SetFC Default is White (appears grey with default transparency of 50 on a black background). Filled [commands] Fill path described by [commands], using fill color and transparency. Filled paths begin at the start of the described path or any PenDown command, and are filled at the end of the described path or any PenUp command. Self intersecting paths produce filled and unfilled areas (evenodd fill method). Text: ===== Print "foo prints foo Prints text. Use quote to prevent evaluation. PR "foo Each print command starts on a new line. Print ["foo ["bar]] prints foo bar Outer (but not inner) list brackets removed. Print ["rgb "cyan cyan "range 0 "to 99] prints rgb cyan [0 99 99] range 0 to 99. Print ["screen "size SS "x SS "pixels] prints screen size 401 x 401 pixels. Note: Print text is laid over the graphics screen, it can be copied but not edited. To print an empty line, use Print ". To print an empty space, use Print Char 32. Show Same as Print but outer list brackets shown. Also, quotes shown. Label add text to the graphics screen. Same formats as Print above. written horizontally, in the pen color. if PenUp, aligned centrally at turtles position. if PenDown, aligned (left, right, top, bottom), depending on turtle heading and also aligned within the screen area. eg pu setpos [SS SS] pd label "topright Ascii "c Output Unicode of character c. Ascii " is 0. Char n Output character of Unicode n, 32-126. Note: Only use for printing / labelling characters. char 32 is a blank space char 33 to 64 !"#$%&'()*+,-./0123456789:;<=>?@ char 65 to 96 ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` char 97 to 126 abcdefghijklmnopqrstuvwxyz{|}~ To convert between lower and upper case, subtract or add 32. Arithmetic: =========== all inputs and output are numbers. Sum n m Output sum, n+m. n + m (infix operator) Product n m Output product, n*m. Prod n m n * m (infix operator) Difference n m Output difference, n-m. Diff n m n - m (infix operator) Note: 8 -3 won't work as interpreted as two numbers 8 and -3. Quotient n m Output quotient, n/m. Error if m is 0. Quot n m n / m (infix operator) Modulo n m Output n modulo m, n%m. Error if m is 0. Mod n m n % m (infix operator) Power n m Output n to the power m, n^m. Pow n m Error if both n and m are 0, or, if n is negative and m is not an integer. n ^ m (infix operator) Minus n Output minus n. Remainder n m Output remainder of integer n / integer m. Error if m is 0. Rem n m (not the same as modulo when n is negative) Random n Output a random integer in range 0 to n-1. Error if n is not a positive integer. Rand n eg. Random 4 outputs 0, 1, 2 or 3 Integer num/str Output integer part of n, if n is a number or a string of digits. Int num/str eg. Int "123 outputs 123, so converts a string to an integer. Abs n Output absolute value of n. Exp n Output the value of E (Eulers constant) to power n. Exp 1 is 2.718281828459045. Ln n Output natural logarithm (base e) of n. Error if n is negative or 0. Log10 n Output common logarithm (base 10) of n. Error if n is negative or 0. Round n Output n rounded to nearest integer. Sign n Output -1 if n<0, or 1 if n>0, else 0. Sqrt n Output square root of n. Error if n is negative. Sin n Output sine of n (degrees). Cos n Output cosine of n (degrees). Tan n Output tangent of n (degrees). ArcTan n Output angle (degrees) whose tangent is n. PI Output constant, 3.141592653589793 SqRt2 Output constant, 1.4142135623730951 SS Output constant, 401. Use to indicate a value is dependent on Screen Size. Lists Strings: ============== data types: str -string, num -number, t/f -boolean, lst -list chr -character, single a-z, 0-9 or underscore ind -index, of character in string or thing in list wrd -word, a string, number or boolean thg -thing, a word or list Pick str/lst Output random item from list or character from string. If Emptyp output null. To pick from a group of numbers, put numbers in a list. Count str/lst Output number of items in a list or characters in a string. Emptyp str/lst Output true if list or string is empty ([] or "), else false. Constructs: =========== List thg/lst thg/lst Output list of first thing/list and second thing/list. Sentence thg/lst thg/lst Output flattened list of first thing/list and second thing/list. SE thg/lst thg/lst Word wrd wrd Output string of first word and second word. FPut chr str Output string with char added as first character. FPut thg lst Output list with thing added as first item. LPut chr str Output string with char added as last character. LPut thg lst Output list with thing added as last item. SetItem ind str chr Set the indexed character in a string to char. Index must be an integer between 1 and Count string. SetItem ind lst thg Set the indexed item in a list to thing. Index must be an integer between 1 and Count list. Destructs: ========== First str/lst Output first item in a list, or character in a string. If Emptyp output null. ButFirst str/lst Output list without first item, or string without first character. BF str/lst Last str/lst Output last item in a list, or character in a string. If Emptyp output null. ButLast str/lst Output list without last item, or string without last character. BL str/lst Item ind str Output the indexed character from string. Index must be an integer between 1 and Count. Item ind lst Output the indexed item from list. Index must be an integer between 1 and Count. Remove chr str Output string with every occurrence of char removed. Remove wrd lst Output list with every occurrence of word removed. Library Procedures ================== Capital str Output string with first character capitalised. Convert num b Output number converted to base b. Decrement num Output number-1. Distance [x y] [x y] Output distance between two points. Double num Output 2*number. Evenp num Output true if number is even, else false. Factorial num Output factorial of number. Fibonacci num Output fibonacci of number. Half num Output number/2. HCF m n Output highest common factor of numbers m n. Increment num Output number+1. LCM m n Output lowest common multiple of numbers m n. Least m n Output least of m n. Most m n Output most of m n. Oddp num Output true if number is odd, else false. Polar2Rect ang dist Output rectangular from polar coordinates. Reverse str/lst Output list or string with items or characters in reverse order. Comparison: =========== output false if either input is a list, or words (numbers, strings or booleans) are different data types. Equalp wrd1 wrd2 Output true if wrd1 is the same as wrd2, else false. Case insensitive so "a = "A is true. Note 4 = "4 is false. wrd1 = wrd2 (infix operator) NotEqualp wrd1 wrd2 Output true if wrd1 is not the same as wrd2, else false. wrd1 <> wrd2 (infix operator) Lessp wrd1 wrd2 Output true if wrd1 is less than wrd2 (numerical or alphabetical), else false. wrd1 < wrd2 (infix operator) LessEqualp wrd1 wrd2 Output true if wrd1 is less than or equal to wrd2 (numerical or alphabetical), else false. wrd1 <= wrd2 (infix operator) Greaterp wrd1 wrd2 Output true if wrd1 is greater than wrd2 (numerical or alphabetical), else false. wrd1 > wrd2 (infix operator) GreaterEqualp wrd1 wrd2 Output true if wrd1 is greater than or equal to wrd2 (numerical or alphabetical), else false. wrd1 >= wrd2 (infix operator) Logic: ====== inputs are true or false. And t/f t/f Output true if both inputs are true, else false. Or t/f t/f Output true if either input is true, else false. Not t/f Output true if input is false. Output false if input is true. Loops: ====== For ["name start limit step] [commands] Repeat commands with var_name from start to limit with step size. Name needs preceeding quote. eg For ["a 4 11 2] [print :a] will print 4 6 8 10. Limit can be less than start value. eg For ["a 4 -5 2] [print :a] will print 4 2 0 -2 -4. Sign of step ignored. Repeat n [commands] Repeat [commands] n number of times, n must be a positive integer (or 0). Note: no Forever command, just use a large number. RepCount Within a repeat loop, output the current repetition count, starting at 0. Note: RepCount is only updated at the start of each new repeat loop. Stop Stop the current loop / procedure and return to containing loop / procedure. Output r Stop the current procedure and output result (thing) as an input to the containing loop / procedure. OP r Can only be used within a procedure. Pause Pause and display alert box. Select 'OK' to continue or 'Cancel' to stop. Wait n Wait n milliseconds (approx). Use with a fast speed to create animation effect. Conditionals: ============= If t/f [commands] If true, run [commands]. If false, [commands] not evaluated. IfElse t/f [commands_1] [commands_2] If true, run [commands_1], [commands_2] not evaluated. If false, run [commands_2], [commands_1] not evaluated. Variables: ========== Names are valid strings, (called symbols), must start with a letter and only include letters a-z, digits 0-9 and underscore. Make "name thg Assign value of thing to variable named name. If the name already exists, update its value, else create a new variable. To recall the value of symbol "name, use :name. eg. Make "name :name + 1. Global "name Make "name global in scope, (instead of dynamic). Can only be used within a procedure. Thing "name Output value of "name. Same as :name. (quote to colon) Run "name Run procedure named "name. Note that the procedure cannot take any inputs. (quote to none) General: ======== Date Output list, [mm dd], month and date. Time Output list, [hh mm], hours and minutes. Diagnostics: ============ Command line entries. PrintOutAll Printout variables (name, value), and user defined procedures (name, number of inputs). POA Note: Use ResetAll to clear all memories. Parse command Print out parsed command to help diagnose parser. eg Parse to a pr "b end
Drawing ======= Arc Wave Archimedes Bifur Diag Chessboard Clover Leaf Clover Wave Dartboard Dudeney Eye Sector Ferris Wheels Flower Bunch Golden Spiral Haiku Poetry Kam Torus L-Systems Moon & Stars Orbs_1 Orbs_2 PacMan Ghost Petals Pi Island Polygons Poly Spiral Poly Weave Rose Curves Spirograph Spiro_2 Spore Stars String Arts Surface 3d Recursion ========= Brain Curve C-Curve Chirral Star Dragon Curve Fern Fractal Flowsnake Gasket Harriss Spiral Hilbert Curve Hilbert2 Curve Peano Curve Sier Curve Sier Tri Snowflake Sphinx Square Corner Tree Blossom Tree Curve Tree Lean Unit Curve Wirth Curve Illusions ========= After Image Bulge Entwined Kanizsa Neon Patch Ripple Whites Zoom Test/Demo ========= Char Circles Demo Star Fill Paths Grids Hues Labels Mod v Rem Palette Pen Colors Position Recursion PrintShows rgb_Colors Procedures ========== Capital Conv Base Decrement Distance Double Evenp Factorial Fibonacci Half HCF Increment LCM Least Most Oddp Polar-Rect Reverse Shapes ====== Axe Bauble Button Chevron Clover Cross Drop Egg Ellipse Heart Horseshoe Kidney Kite Lens Lune Paragram Polygon Prop Quad Quatra Rectangle Rhombus Salinon Sector SectorAn Square Stadium Star Star5 Triquetra Tulip YinYang Select a program to copy its code into the editor. Procedures and shapes insert code at the text cursor position. Random programs produce a different image each time they're run. Comments ## can be removed to 'commented in' extra code. Recursive programs use a For loop to draw each curve. Adjust the min, max (carefully) and step values.