A.1 Movement of the turtle; pen and color settings

These first primitives govern the movement of the turtle.



forward, fd n



Moves the turtle forward n steps in the direction it is currently facing.



back, bk n



Moves the turtle backwards n steps in the direction it is currently facing.



right, rt n



Turns the turtle n degrees towards the right in relation to the direction it is currently facing.



left, lt n



Turns the turtle n degrees towards the left in relation to the direction it is currently facing.



circle R



Draws a circle of R radius around the turtle.



arc R cap1 cap2



Draws an arc of R radius around the turtle. This arc is inscribed between the caps cap1 and cap2.



home



Returns the turtle to its initial position, that is, the co-ordinates [0 0] with a heading of 0 degrees.



setpos, setposition list



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)



setx x



Moves the turtle horizontally to the point x on the x-axis



sety y



Moves the turtle vertically to the point y on the y-axis



setxy x y



Identical to setpos [x y]



setheading, seth n



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.



label arg



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.



dot list



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?



showturtle, st



Makes the turtle visible on the screen.



hideturtle, ht



Makes the turtle invisible on the screen.



clearscreen, cs



Empties the drawing area.



wash



Erases the drawing area but leaves the turtle in the same place.



resetall



Initialize the XLOGO interface to standard values.

and empties the drawing area.



pendown, pd



The turtle will draw a line when it moves.



penup, pu



The turtle will not draw a line when it moves.



penerase, pe



The turtle will rub out any marks that it meets.



penreverse, px



Lower the pen and put the turtle in inverted mode.



penpaint, ppt



Lower the pen and put the turtle in classic drawing mode.



setpencolor, setpc color



Sets the pen color. See p.162.



setscreencolor, setsc color



Sets the screen color. See p.162.



pos, position



Gives the current position of the turtle.Eg: pos returns [10 -100]



x



Returns the x-coordinate of the turtle position.



y



Returns the y-coordinate of the turtle position.



z



Returns the z-coordinate of the turtle position. (Only available in 3D mode)



heading



Gives the bearing or heading of the turtle (cf setheading)



towards list



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.



distance 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.



pencolor, pc



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.



screencolor, sc



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



Window configuration: the turtle can travel outside the drawing area (but of course, it cannot draw there).



wrap



Window configuration: if the turtle leaves the drawing area, it will reappear on the opposite side!



fence



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 ...).



perspective



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



findcolor, fc list



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.



setpenwidth, setpw n



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.)



penwidth, pw



Returns the thickness of the pen nib in pixels.



setPenShape, setps 0-1



Set the pen shape.



PenShape, ps



Returns the pen shape.



setDrawingQuality, setdq 0-1-2



Set the drawing Quality.



DrawingQuality, dq



Returns the drawing Quality.



setscreensize list



Set the screen size to the dimension contained in the list. setscreensize [1000 1000]



screensize



Returns the current screen size in a list. setscreensize [1000 1000]



setshape n



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).



shape



Returns the number that represents the shape of the turtle.



setfontsize, setfs n



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.



fontsize



Returns the size of the font when you write on the screen with the primitive label.



setfontname, setfn n



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.



setfontjustify list



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.

Here are all possible cases: setfontsize 50 label "XLogo

pict pict pict
setfontjustify [2 0] setfontjustify [1 0] setfontjustify [0 0]
pict pict pict
setfontjustify [2 1] setfontjustify [1 1] setfontjustify [0 1]
pict pict pict
setfontjustify [2 2] setfontjustify [1 2] setfontjustify [0 2]





fontjustify



Returns a list that represents the text alignment around the turtle when you write on drawing area with the primtive label



fontname



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.



setseparation, setsep n



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.



separation,sep



Provides the current ratio between the drawing zone and the history zone.



grid a b



Draw a grid. Each square has dimension a and b.



stopgrid



Erase grid.



setgridcolor color



Allow the user to choose a custom color for the grid. Eg: setgridcolor red



gridcolor



Returns current grid color.



grid?



Return true if the grid is drawn, else return false.



axis n



Draw horizontal and vertical axis. The distance between two divisions is n steps.



xaxis n



Draw only horizontal axis. The distance between two divisions is n steps.



yaxis n



Draw only vertical axis. The distance between two divisions is n steps.



stopaxis



Erase both axis.



setaxiscolor, sac color



Allow the user to choose a custom color for the axis. Eg: setaxiscolor green



axiscolor



Returns current axis color.



xaxis?



Return true if the horizontal axis is drawn, else return false.



yaxis?



Return true if the vertical axis is drawn, else return false.



setzoom a



Zoom on the drawing screen. In fact, the number a represents the scale regarding to the original image size fixed in the preference panel.



zoom



Returns the current zoom scaling.



labellength arg



Returns the length that needs the word or the list to be displayed on the screen with the primitive label using the current font.



zonesize



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.



message, msg list



Shows the message in list in a dialog box, the program stops until the user has clicked the button "OK"

A.1.1 A word on colors

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]
pict
1 red [255 0 0]
pict
2 green [0 255 0]
pict
3 yellow [255 255 0]
pict
4 blue [0 0 255]
pict
5 magenta [255 0 255]
pict
6 cyan [0 255 255]
pict
7 white [255 255 255]
pict
8 gray [128 128 128]
pict
9 lightgray [192 192 192]
pict
10 darkred [128 0 0]
pict
11 darkgreen [0 128 0]
pict
12 darkblue [0 0 128]
pict
13 orange [255 200 0]
pict
14 pink [255 175 175]
pict
15 purple [128 0 255]
pict
16 brown [153 102 0]
pict
 
 # These three instructions are the same
 setsc orange
 setsc 13
 setsc [255 200 0]

A.1.2 Animation Mode

There are two primitives which allow execution of commands witout the turtle displaying them: animation and stopanimation



anim, animation



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.



stopanim, stopanimation



Animation mode is finished: you switch back to classical mode. You can see the turtle’s moves on screen.



repaint



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.
pict

A.1.3 Writing in the text area with the primitive print or write

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



cleartext, ct



Empties the area containing the command and comment history.



pr, print arg



Shows the argument specified in the history zone.
 print "abcd --------> abcd
 pr [1 2 3 4] ----> 1 2 3 4
 pr 4 ------------> 4



write arg1



The same as for the print primitive but doesn’t go back to the start of the line.



setTextSize, setTS n



Define the size of the font in the command history. Only valid with the primtive print



textsize, ts



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.



TextColor, tc



Returns the color of the font with the primitive print in the command history.



setTextName, setTN n



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.



TextName, tn



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.



setstyle, setsty arg



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



sty, style



Returns a list which contains the differents styles used for the primitive print.