- getting started
This program draws a dozen random lines and labels each point with its co-ordinates. It has 4 procedures: New, RanPoint, LabXY and Go. To run the program:
# set default screen, pen and turtle values
ResetAll SetScreenSize [400 400] HideTurtle
SetSC Black SetPC Green SetPS 1 PenUp
SetXY (Random 340)-170 (Random 380)-190
SetPC White Label Pos
New SetFontJustify [1 1] LabXY
SetPenWidth 2 PenDown Repeat 12 [
SetPC (1+Random 6) RanPoint LabXY Wait 30]
SetPC (1+Random 6) Home
XLogo should create the graphic as shown on the right.
To clear the graphics window and reset the turtle, type in 'new'.
Check out the code comments and explanation below.
'New' sets the screen to black, hides the turtle and lowers the pen.
'Ranpoint' picks a random pixel within the graphics window. Both x and y axis range from -200 to +200 pixels. Points must not be too close to the window edges, or the labels can partly disappear.
'LabXY' labels each point with the turtles X abd Y position. Each label is printed centred on the point.
the New, RanPoint and LabXY procedures. It also picks a random
pen color between 1 and 7, and pauses for half (30/60) second between each line.
Finally, the pen returns home.