
When you start KTurtle you will see something like this:

In this Getting Started guide we assume that the language of the TurtleScript commands is English. You can change this language with the → submenu. Be aware that the language you set here for KTurtle is the one you use to type the TurtleScript commands, not the language used by KDE on your computer and used to display the KTurtle interface and menus.
You must have noticed the turtle in the middle of the canvas: you are just about to learn how to control it using commands in the editor.
Let us start by getting the turtle moving. Our turtle can do 3 types of moves, (1) it can move forwards and backwards, (2) it can turn left and right and (3) it can go (jump) directly to a position on the screen. Try this for example:
forward 100 turnleft 90
Type or copy-paste the code to the editor and execute it (using → ) to see the result.
When you typed and executed the commands like above in the editor you might have noticed one or more of the following things:
That — after executing the commands — the turtle moves up, draws a line, and then turns a quarter turn to the left. This because you have used the
forward
and theturnleft
commands.That the color of the code changed while you where typing it: this feature is called intuitive highlighting — different types of commands are highlighted differently. This makes reading large blocks of code more easy.
That the turtle draws a thin black line.
Maybe you got an error message. This could simply mean two things: you could have made a mistake while copying the commands, or you should still set the correct language for the TurtleScript commands (you can do that by choosing the → submenu).
You will likely understand that forward 100
instructed the turtle to move forward leaving a line, and that turnleft 90
instructed the turtle to turn 90 degrees to the left.
Please see the following links to the reference manual for a complete explanation of the new commands: forward
, backward
, turnleft
, and turnright
.
The first example was very simple, so let us go on!
reset canvassize 200,200 canvascolor 0,0,0 pencolor 255,0,0 penwidth 5 go 20,20 direction 135 forward 200 turnleft 135 forward 100 turnleft 135 forward 141 turnleft 135 forward 100 turnleft 45 go 40,100
Again you can type or copy-paste the code to the editor or open the arrow
example in the submenu and execute it (using → ) to see the result. In the next examples you are expected to know the drill.
You might have noticed that this second example uses a lot more code. You have also seen a couple of new commands. Here a short explanation of all the new commands:
After a reset
command everything is like is was when you had just started KTurtle.
canvassize 200,200
sets the canvas width and height to 200 pixels. The width and the height are equal, so the canvas will be a square.
canvascolor 0,0,0
makes the canvas black. 0,0,0
is a RGB-combination where all values are set to 0
, which results in black.
pencolor 255,0,0
sets the color of the pen to red. 255,0,0
is a RGB-combination where only the red value is set to 255
(fully on) while the others (green and blue) are set to 0
(fully off). This results in a bright shade of red.
If you do not understand the color values, be sure to read the glossary on RGB-combination.
penwidth 5
sets the width (the size) of the pen to 5
pixels. From now on every line the turtle draw will have a thickness of 5
, until we change the penwidth
to something else.
go 20,20
commands the turtle to go to a certain place on the canvas. Counted from the upper left corner, this place is 20 pixels across from the left, and 20 pixels down from the top of the canvas. Note that using the go
command the turtle will not draw a line.
direction 135
set the turtle's direction. The turnleft
and turnright
commands change the turtle's angle starting from its current direction. The direction
command changes the turtle's angle from zero, and thus is not relative to the turtle previous direction.
After the direction
command a lot of forward
and turnleft
commands follow. These command do the actual drawing.
At last another go
command is used to move the turtle aside.
Make sure you follow the links to the reference. The reference explains each command more thoroughly.