Qogo (Pronounced kwo-go is a Langiage based on a mix of Tcl and Logo.
It implements the Turtle graphics primatives for drawing on a canvas.
The program has been designed to teach 8 to 10 year olds the principles of programming.
That is Sequence, Selection , and Iteration
The program can be used to design complex pictures using simple commands.
The Application is designed to teach children of age ranging from 5 to 10 years old the basics of programming.
It does this by representing the contructs in as simple a way as possible.
The Application teaches both programming as well as simple geometry without the complexities of trigonometry.
It also helps with imagination as the symbols on the screen are abstract concepts.
On the screen is a Turtle represented by a triangle shape. The turtle can be made to draw shapes on the screen by issuing a sequence of instructions. The Turtle carries a selection of pens and can select one to draw in different colours and widths.
To draw simple shapes that use onle horizontal lines only four simple commands need to be understood. These are Forward, Right, Pen up, Pen down, as an example ,. to draw a square of one grid unit you would issues the following instructions:
Unfortunately when more complex shapes are tried and angles other than 90 degrres are involved there is no simple way of calculating how far forward to move the turtle to make lines that
would connect with the grid. To solve this problem the concept of a Puppy is introduced and explained below.
It is suffice to understand that the Puppy allows diagonal lines to be drawn without
having to use angles or square roots.
The Turtle has a Puppy that normally walks around underneath the Turtle so is not seen. The Puppy is represented by a square on the screen.
The Puppy only understands two instructions, PuppyStay and PuppyCome.The puppy concept operates as follows.
If you are reading this document from the help button of the application then you can skip this section.
The program is distributed as a zip file from here.
Download the zip file and run your extractor program. Extract all files to a new folder.
Under Windows Locate the folder in Explorer and click on the file Qogo.tcl. The application window should appear.
Under unix based systems, perform above and change to the qogo directory and run the command wish Qogo.tcl
The program uses sqlite and the htmlwidget packages. Binaries of these libraries are included in the distribution. They will be used in preference to any other copies on the machine as sqlite keeps changing the database format.
The screen layout is as follows:
1 Button Row 1 | ||
2 Button Row 2 | 8 Options | |
3 Command List |
9 Parameters | 5 Drawing Area --------------------------------------------------------- |
4 Program List | ||
6 Command Entry: | ||
7 ------ Status Messages -------- |
These are the buttons that you will mostly when operating the program. Their function is outlined below.
Buttons that are not used as often.
The four buttons located next to the word Test all operate on test files. A Test is a drawing that has been saved and can be used as a pattern that someone has to fry and follow.
The two buttons located next to the word Programmes all operate on test files. A Test is a drawing that has been saved and can be used as a pattern that someone has to fry and follow.
The four buttons located next to the word Pics all operate on picture files. The current picture can be saved and reloaded as a background that stays even after a new picture is drawn and erased.
The Button labeled Help displays this help screen.
The list that appears on the very left of the display is the list of known Qogo instructions. Following an instruction may be 1 or more question mark (?) symbols. These stand for parameters that must be added to the instruction before it can be run.
IE
The forward command need to know how far? to go, so a number representing the
number of grid spaces to advance is supplied as the first and only parameter.
For Example.
Forward 1 - Moves one space
Right 90 - Turns right by 90 degrees.
Repeat 4 {Forward 1 Right 90} - Repeat 4 times the sequence Forward 1 Right 90.
When an instruction is selected , the parameter names are displayed in the Status message box as a hint as to what information should be supplied as arguments.
See Syntax for a command summary
This is the sequence ( a list) of instructions that have been requested to be performed when the run button is clicked. Either they have been entered from typing into the Comand box or by clicking instructions in the Command words box.
The results of the instructions are displayed in this area. The display is divided into squares called a grid. Each instruction operates in grid units. To change the visible size of the image use the ++ and -- buttons.
When the cursor is focused on this box, Instructions can be typed in. On pressing the Enter key, they are executed and transferred to the Program list box.
More than one instruction can be given on a single line and they will be executed together.
When the run button is clicked each line is executed and then the screen is updated. If all the instructions are entered on one line, the picture will not show until all the drawing command have been completed.
When typing the Tab key may be pressed to complete the typing of the instruction. If the part of the word typed matches more that one command then both commands will be highlighted and only the part of the word that is common to both instructions will be typed in automatically.
Information that has no were else to be displayed is placed in this box at the bottom of the display.
The coloured buttons are short cuts for changinfg the colour of the pen. Clicking on the button changes sets the pen colour. Clicking with the right mouse button changes the background colour of the drawing area.
The operation of the application can be changed by these settings:
This box is used when creating a new instruction word. See command parameters in the Syntax section for more information.
A Simple introduction to the application.
The command should now appear on the Program List box.
Also the turtle should have executed the command.
The above instructions can be saved under a given name. This name then becomes an instruction that can be typed in. The one name will execute all the instructions
Consider the following task.
Design a new instruction that draws a circle as a series of steps.
Whout being able to supply parameters to the instruction, we would have to create a new instruction for each size of circle we wanted to draw.
We use the box above the Program List box to specify parameters that will be supplied to the new instruction should it be saved.
The format of the parameter list is :
A Special character ^ is reserved as a prefix to the name for use in the following case.
When the parameter is designed to not be a number, the name should be prefixed with ^.
Note this only applies to the name given in the Parameter box, do not prefix the parameter name with a ^ when referencing it from the program.
The reason why this is necessay is outside the scope of this document. It is suggested that you look at the instructions for commands such as DoCircle and GoAround to see why when this obfuscated syntax is required.
If you are only ever expecting numbers as parameters then you can ignore the use of ^.
Tests can be created simply by drawing a shape and then saving it using the
Test Save button.
The file can then be loaded using Tests Load and it will now appear
drawn with dashed lines.
The syntax can be though of as Backwards Forth .
It consists of a stream of tokens that are consumed from left to right.
The First token in the list is the name of a command that is called with the rest of the tokens as parameters. The command consumes as many of these parameters as required and performs its function.
Before returning to it's caller the command will execute all parameters that have not been consummed.
Each parameter that is consumed is evaluated as a number.
If the token is not a number or a known variable then the token is executed as a command.
Commands that are called with insufficient parameters, steal parameters from the command that invoked them.
An example, consider :
For the purpose of animating the process of drawing the application allows the program to be broken into a number of lines, with each line having one or more commands.
For the purposes of explaining how the intperpreter works, it should be assumed that the program is one continuous list of tokens that are executed with one invokation.
There are only eight core instructions. These are
There are mirror image commands for convienience:
To save typing there are these commands
All other instructions are based on these. All instructions begin with a capital letter.
The following table descibes each command , its parameters, and its purpose.
Pen | up down |
|
Drawing only happens when the pen is down. Use Pen up to move without leaving a trail. | ||
Forward | amount | |
Moves in the current direction, amount number of grid spaces. | ||
Colour | ^type | |
Changes the pen colour, Valid colours are: red blue green yellow purple white black brown | ||
Home | ||
Return the turtle to the starting position without drawing any trail. | ||
Clear | ||
Erases all the lines in the drawing. | ||
Width | n | |
Erases all the lines in the drawing.Makes the pen x pixels wide. | ||
Repeat | num ^what | |
Repeats the instruction what num number of times. To repeat more than one instruction , enclose them between { and } characters In the Program List and alternate format may be used. What may be omitted and furhter in the list a End Repeat instruction may be inserted. All instructions between the Repeat and End Repeat will be repeated. Note that this is only down for ease of entry. A variable called Loop is incremented by one for each iteration of repeat. To make a square use Repeat 4 {Forward 1 Right 90} |
||
Loop | ^var start end incr ^what | |
Repeats the instructions contained in what. At the start sets the variable called var to the value start. After each loop the variable is incremented by incr. If the new value is less then end the loop continues.
To make a spiral use Loop I 1 20 1 {Forward I Right 90} |
||
The following are basic mathmatic instructions. | ||
Add + |
num1 num2 | |
Returns the sum of num1 and num2 | ||
Sub - |
||
Returns the difference of num1 and num2 | ||
Mul * |
num1 num2 | |
Returns num1 multiplied by num2 | ||
Div / |
num1 num2 | |
Returns num1 divided by num2 | ||
Short cut Commands | ||
GoAround | ^dir steps ^what | |
Turns around a circle in steps steps. At each step execute the commands in what
For example do draw a square use GoArround Right 4 {Forward 1} |
||
Circle | size | |
Draw a circle centered on the current position of diameter size
The global variable Steps determines the number of steps taken to draw the circle. If Steps is 8 then an Octagon would be drawn. |
||
DoCircle | size ^pen ^what | |
Like circle but at each virtex, the command what is executed.
To Draw a Hexagon of Triangles use Steps 6 DoCircle 6 down {Steps 3 Circle 1} |
||
Guess | ||
Choose a colour randomly. | ||
Setv | ^var value | |
Sets a global variable var to the value given value | ||
SetL | ^var ^val | |
Sets the global variable var to the literal val | ||
HalfCircle | size | |
Draws a half circle to th Right of the current position. | ||
If | expr ^what | |
If expr evaluates to true then execute what.
An alternate form can be used in the Programme list. If what is ommitted and the instruction End If is placed in the list, then all the instructions between the If and End If become the what parameter. |
||
IfNot | expr ^what | |
If expr evaluates to false then execute what. | ||
Trigonometry Commands | ||
Sin | angle | |
Returns the sine of angle , where angle is in degrees | ||
Cos | angle | |
Returns the cosine of angle , where angle is in degrees | ||
Tan | angle | |
Returns the tangent of angle , where angle is in degrees | ||
ATan | x y | |
Returns the angle whose tangent is x / y , | ||
Sqrt | x | |
Returns the square root of x | ||
Miscelleanous Commands | ||
Text | size ^txt | |
Adds the characters txt size grid units high
Example usage Text 1 {Hello World} |
||
SP | ||
Moves one grid space to the right without leaving a trail. | ||
Z A C | ||
The Letters Z, A, and C with spaces. | ||
Scale | x | |
Makes the length of all moves x times longer. | ||
Steps | x | |
Sets the global variable Steps which is used by some commands to
determine how many sides a polygon is drawn with. It is short cut for Setv Steps x To draw a square use Steps 4 Circle 1 To draw a triangle use Steps 3 Circle 1 To draw a octagon use Steps 8 Circle 1 To draw a circle use Steps 32 Circle 1 |
||
Nil Null |
||
The null value. Nuls cannot be used as arguments. This variable is used to pass {} as a parameter to a function. | ||
Parts of this programme were developed with Open Source software and the source for these parts are included in the distribution.
I would like to aknowledge all those that have contributed ideas and techniques to the TCL Wiki as they may have lead to improvements in this code.
The program is developed in the T.C.L programming language.
Information about programming in Logo in TCL can be found on the TCL Wiki Logo Page
More T.C.L software can be found at qs.co.nz/Tcl/.
To contact the Author about this programme click here .
NOTE:
If you don't have the work Qogo in the subject, the message will not be devlivered.