These first primitives govern the movement of the turtle.
Moves the turtle forward n steps in the direction it is currently facing.
Moves the turtle backwards n steps in the direction it is currently facing.
Turns the turtle n degrees towards the right in relation to the direction it is currently facing.
Turns the turtle n degrees towards the left in relation to the direction it is currently facing.
Draws a circle of R radius around the turtle.
Draws an arc of R radius around the turtle. This arc is inscribed between the caps cap1 and cap2.
Returns the turtle to its initial position, that is, the co-ordinates [0 0] with a heading of 0 degrees.
Moves the turtle to the co-ordinates specified by the two numbers in the list (x specifies the x-axis and y the
y-axis)
Moves the turtle horizontally to the point x on the x-axis
Moves the turtle vertically to the point y on the y-axis
Identical to setpos [x y]
Orients the turtle in the specified direction. 0 corresponds to a position facing vertically upwards. The heading when
the turtle is rotated is then based on compass bearings.
Draw the specified word or list at the turtle’s location, and following the direction it is facing.
Eg: label [Hello there!] will write the sentence "Hello there!" wherever the turtle is, and corresponding to its
bearing or heading.
The point defined by the co-ordinates in the list will be highlighted (in the pen colour).
This second group sets out the primitives which allow the properties of the turtle to be adjusted. For example,
should the turtle be visible on screen? What colour should it draw when it moves?
Makes the turtle visible on the screen.
Makes the turtle invisible on the screen.
Empties the drawing area.
Erases the drawing area but leaves the turtle in the same place.
Initialize the XLOGO interface to standard values.
- PenColor: black
- ScreenColor:white
- Animation mode: disabled
- Text and Graphics Font: Dialog 12 pts
- Pen shape: square
- Drawing quality: normal
- Turtles allowed: 16
- Mode trace: disabled
- Screen size: 1000x1000
and empties the drawing area.
The turtle will draw a line when it moves.
The turtle will not draw a line when it moves.
The turtle will rub out any marks that it meets.
Lower the pen and put the turtle in inverted mode.
Lower the pen and put the turtle in classic drawing mode.
Sets the pen color. See p.162.
setscreencolor, setsc color |
Sets the screen color. See p.162.
Gives the current position of the turtle.Eg: pos returns [10 -100]
Returns the x-coordinate of the turtle position.
Returns the y-coordinate of the turtle position.
Returns the z-coordinate of the turtle position. (Only available in 3D mode)
Gives the bearing or heading of the turtle (cf setheading)
The list must contain two numbers representing co-ordinates. Gives the heading which the turtle must follow to go
towards the point defined by the co-ordinates in the list.
The list must contain two numbers representing co-ordinates. Gives the number of steps between the current
position and the point defined by the co-ordinates in the list.
Gives the current colour of the pen. This colour is specified by a list [r g b] where r is the red component, b the blue
and g the green.
Gives the current colour of the screen (background). This colour is specified by a list [r g b] where r is the red
component, b the blue and g the green.
Window configuration: the turtle can travel outside the drawing area (but of course, it cannot draw
there).
Window configuration: if the turtle leaves the drawing area, it will reappear on the opposite side!
Window configuration: the turtle is confined to the drawing area. If it is about to go outside, an error message will
let you know, and give you the maximum number of steps the turtle can move before the exit point is reached (to
within 1 or 2 steps ...).
Window configuration: the turtle can move through 3d Space. (See Special Section A.2 for this mode). To quit this
mode, use one of these primitives window, wrap or fence
Returns the colour of the list coordinates pixel. This color is determined by a [r g b] list where r is red, g is green
and b is blue.
Defines the thickness of the pen nib in pixels. The default is 1. The pen has a square or round nib. (Other shapes
will be provided in future versions.)
Returns the thickness of the pen nib in pixels.
Set the pen shape.
Returns the pen shape.
setDrawingQuality, setdq 0-1-2 |
Set the drawing Quality.
Returns the drawing Quality.
Set the screen size to the dimension contained in the list. setscreensize [1000 1000]
Returns the current screen size in a list. setscreensize [1000 1000]
You can choose your preferred turtle with the second tab of menu Options-Preferences.... But you
can choose your favourite turtle with setshape. The number n goes from 0 to 6. (0 is the triangular
shape).
Returns the number that represents the shape of the turtle.
When you write on the screen with the primitive label, it’s possible to modify the size of the font with
setfontsize. The size of the font is 12 by default.
Returns the size of the font when you write on the screen with the primitive label.
Select the font number n when you write on the screen with the primitive label. You can find the link between
number and font in Menu→OptionsvPreferences→Tab Font.
When you write on the screen with the primitive label, it’s possible to specify the text alignment around the turtle.
The list contains two integers.
- The first integer represents the horizontal alignment.
- 0: left horizontal alignment.
- 1: center horizontal alignment.
- 2: right horizontal alignment.
- The second integer represents the vertical alignment.
- 0: bottom vertical alignement.
- 1: center vertical alignment.
- 2: top vertical alignment.
Here are all possible cases: setfontsize 50 label "XLogo
| | |
setfontjustify [2 0] | setfontjustify [1 0] | setfontjustify [0 0] |
| | |
setfontjustify [2 1] | setfontjustify [1 1] | setfontjustify [0 1] |
| | |
setfontjustify [2 2] | setfontjustify [1 2] | setfontjustify [0 2] |
|
Returns a list that represents the text alignment around the turtle when you write on drawing area with the
primtive label
Returns a list with two elements. The first is the number corresponding to the font used when you
write on the screen with the primitive label. The last element is a list which contains the name of the
font.
Determines the ratio between the graphic screen and the history zone. The number n must be included between 0
and 1. When n equals 1 the drawing zone uses all the space, when n equals 0, the history zone uses all the
window.
Provides the current ratio between the drawing zone and the history zone.
Draw a grid. Each square has dimension a and b.
Erase grid.
Allow the user to choose a custom color for the grid. Eg: setgridcolor red
Returns current grid color.
Return true if the grid is drawn, else return false.
Draw horizontal and vertical axis. The distance between two divisions is n steps.
Draw only horizontal axis. The distance between two divisions is n steps.
Draw only vertical axis. The distance between two divisions is n steps.
Erase both axis.
Allow the user to choose a custom color for the axis. Eg: setaxiscolor green
Returns current axis color.
Return true if the horizontal axis is drawn, else return false.
Return true if the vertical axis is drawn, else return false.
Zoom on the drawing screen. In fact, the number a represents the scale regarding to the original image size fixed in
the preference panel.
Returns the current zoom scaling.
Returns the length that needs the word or the list to be displayed on the screen with the primitive label using the
current font.
Returns a list which contains four numbers. These integers are the coordinates of the left upper corner of the
drawing zone and the coordinates for the right bottom corner.
Shows the message in list in a dialog box, the program stops until the user has clicked the button
"OK"
Colors are defined in XLOGO with a list of three numbers [r g b] between 0 and 255.
The number r is the red component, b the blue and g the green. Xlogo has 16 predefined colours: you can access
with their rgb list, with a number, or with a primitive. look at this table:
|
Number | Primitives | [R G B] | Color |
|
0 | black | [0 0 0] | |
|
1 | red | [255 0 0] | |
|
2 | green | [0 255 0] | |
|
3 | yellow | [255 255 0] | |
|
4 | blue | [0 0 255] | |
|
5 | magenta | [255 0 255] | |
|
6 | cyan | [0 255 255] | |
|
7 | white | [255 255 255] | |
|
8 | gray | [128 128 128] | |
|
9 | lightgray | [192 192 192] | |
|
10 | darkred | [128 0 0] | |
|
11 | darkgreen | [0 128 0] | |
|
12 | darkblue | [0 0 128] | |
|
13 | orange | [255 200 0] | |
|
14 | pink | [255 175 175] | |
|
15 | purple | [128 0 255] | |
|
16 | brown | [153 102 0] | |
|
# These three instructions are the same
setsc orange
setsc 13
setsc [255 200 0]
|
There are two primitives which allow execution of commands witout the turtle displaying
them: animation and stopanimation
You go into animation mode. The turtle does not draw on the screen anymore but follows the stored line. To update
the drawing on the screen, use the primitive repaint. It is very useful to create an animation or to draw a line
faster.
Animation mode is finished: you switch back to classical mode. You can see the turtle’s moves on
screen.
In animation mode, updates the screen: the image on the drawing area is updated.
To identify animation mode, a camera icon appears in the history window. If you click on the icon, the animation
mode will stop. It’s equivalent to the primitive stopanimation.
This table sets out the primitives which allow the properties of the text area to be adjusted. Primitive
that control the color and the size of the history area, are available only for the primitives print or
write
Empties the area containing the command and comment history.
Shows the argument specified in the history zone.
print "abcd --------> abcd
pr [1 2 3 4] ----> 1 2 3 4
pr 4 ------------> 4
|
The same as for the print primitive but doesn’t go back to the start of the line.
Define the size of the font in the command history. Only valid with the primtive print
Returns the size of the font with primitive print.
setTextColor, setTC color |
Define the color of the font in command history. Valid only with the primitive . See p.162.
Returns the color of the font with the primitive print in the command history.
Select the font number n when you write on the the command history with the primitive print. You can find the
link between number and font in Menu→Options→Preferences→Tab Font.
Returns a list with two elements. The first is the number corresponding to the font used when you write on the
command history with the primitive print. The last element is a list which contains the name of the
font.
Set the format of the text in the text area. You can choose between seven styles: none, bold, italic,
strike, underline, superscript, subscript. If you want several styles together, write them in a
list.
A few examples for formatting text:
setstyle [bold underline] print "hello
hello_____
ssty "strike write [strike] ssty "italic write "\ x ssty "superscript print 2
strike x2
Returns a list which contains the differents styles used for the primitive print.