-This is the script file used for the turtle tutorial. #cls(1) #move(200,100) #setpen(2) #text("T U R T L E T U T O R I A L") #move(195,104) #text("________________________________") #move(198,99) #setpen(7) #text("T U R T L E T U T O R I A L") #move(193,103) #text("________________________________") #setpen(2) #move(30,180) #text("This tutorial explains the ideas behind producing pictures using the turtle") #move(10,200) #text("program. For help on using the menu options within the program itself, select") #move(10,220) #text("Help from the Project Menu.") #move(30,240) #text("The tutorial will cycle through a number of screens automatically. To pause") #move(10,260) #text("the tutorial on a screen, hold down the right mouse button.") #move(60,300) #text("Press to exit the tutorial.") #wait(480) #cls(1) #move(30,140) #text("Turtle uses turtle graphics like logo. It uses an imaginary turtle whose") #move(10,160) #text("position is the current drawing position. The position may be from 0,0") #move(10,180) #text("(top left) to 640,512 (bottom right). The turtle also has a heading,") #move(10,200) #text("which is the direction in which the turtle faces - straight up is a heading") #move(10,220) #text("of zero, right is 90, down is 180, etc:") #set_heading(0) #set_length(60) #set_angle(90) #setpen(7) #move(320,340) #run([F]+[F]+[F]+[F]) #move(316,276) #text("0") #move(308,416) #text("180") #move(382,346) #text("90") #move(234,346) #text("270") #wait(180) #cls(1) #setpen(2) #move(30,140) #text("Turtle takes an input string and produces a drawing dependent on the") #move(10,160) #text("characters in the string:") #setpen(7) #move(100,220) #text("'F' : moves the turtle forward, drawing a line.") #move(100,240) #text("'f' : moves the turtle forward without drawing.") #move(100,280) #text("'-' : makes it turn left.") #move(100,300) #text("'+' : makes it turn right.") #move(100,320) #text("'[' : pushes (saves) the current state.") #move(100,340) #text("']' : pops the current state (retrieves the latest saved one).") #setpen(2) #move(10,400) #text("Other characters are ignored.") #wait(240) #cls(1) #setpen(2) #move(30,140) #text("Several parameters are needed by the program to do its drawing. These") #move(10,160) #text("are specified in control statements, starting with a '#'.") #move(30,180) #text("The statements are:") #setpen(7) #move(100,240) #text("#move(X,Y) : Move the turtle to position X,Y.") #move(100,260) #text("#setpen(N) : Set the drawing colour to N.") #move(100,280) #text("#set_length(N) : Set the distance the turtle moves forward to N.") #move(100,300) #text("#cls(N) : Clear the screen to colour N") #move(100,320) #text("#set_heading(N): Set the turtle heading to N.") #move(100,340) #text("#set_angle(N) : Set the angle through which the turtle turns.") #move(100,360) #text("#text(STRING) : Output the string STRING at current position.") #move(100,380) #text("#wait(N) : Wait N/60 seconds.") #move(30,450) #setpen(2) #text("Any line starting with a '-' is considered a comment.") #wait(240) #cls(1) #move(30,140) #text("A string is drawn using the command #run(STRING), e.g.:") #move(50,200) #text("#run(F) will produce a straight line:") #move(50,280) #text("#set_angle(120)") #move(50,300) #text("#run(F+F+F) will produce a triangle:") #move(50,320) #text("(Forward, Right 120, Forward, Right 120, Forward)") #move(50,380) #text("#set_angle(90)") #move(50,400) #text("#run(F+F+F+F) will produce a square:") #set_length(40) #setpen(4) #set_heading(0) #move(400,220) #run(F) #move(460,300) #set_heading(30) #set_angle(120) #run(F+F+F) #move(400,400) #set_angle(90) #set_heading(0) #run(F+F+F+F) #wait(180) #cls(1) #setpen(2) #move(10,135) #text("Production Rules.") #move(10,137) #text("_________________") #move(30,160) #text("The system allows production rules to be used in conjunction with the") #move(10,180) #text("run string to produce a more complex string which turtle then executes.") #move(30,200) #text("A production rule is of the form:") #move(50,240) #text("A=STRING") #move(10,280) #text("where a is an alphabetic character and STRING is a string of characters.") #move(10,300) #text("The rule means that if the character A exists in the run string, it will") #move(10,320) #text("be expanded to STRING.") #move(30,340) #text("For example, given the string:") #move(50,370) #text("F+C--X+CF") #move(10,400) #text("and the production rule:") #move(50,430) #text("C=GBT") #move(10,460) #text("the string is expanded to:") #move(50,490) #text("F+GBT--X+GBTF") #wait(180) #cls(1) #setpen(2) #move(30,95) #text("For an example, let's look at the Koch curve.") #move(30,135) #text("This is produced by the production rule:") #move(50,175) #text("F=F-F++F-F") #move(30,215) #text("And the statement:") #move(50,255) #text("#run(F)") #move(30,285) #text("The following screen shows successive expansions of the initial string") #move(10,315) #text("(F) from no expansion to 3 expansions. The turning angle is 60.") #wait(180) #cls(1) #setpen(2) #move(8,60) #text("Level String Result") #set_heading(90) #set_length(600) #move(8,64) #run(F) #set_heading(0) #move(50,500) #run(F) #move(360,500) #run(F) #move(18,140) #text("0") #move(60,140) #text("F") #move(18,220) #text("1") #move(60,220) #text("F-F++F-F") #move(18,300) #text("2") #move(60,300) #text("F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F") #move(18,380) #text("3") #move(60,380) #text("F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F") #move(60,400) #text("-F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F") #move(60,420) #text("F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F") #move(56,440) #text("++F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F") #setpen(5) #set_angle(60) #move(370,140) F=F-F++F-F #set_heading(90) #set_length(189) #set_level(0) #run(F) #move(370,220) #set_length(63) #set_level(1) #run(F) #move(370,300) #set_length(21) #set_level(2) #run(F) #move(370,380) #set_length(7) #set_level(3) #run(F) #wait( 120) #cls(1) #setpen(2) #move(30,80) #text("Level 5:") #move(30,82) #text("________") #setpen(5) #move(40,240) #set_length(2) #set_level(5) F=F-F++F-F #run(F) #setpen(2) #move(50,480) #text("The level is controlled by #set_level(LEVEL).") #wait(180) #cls(1) #setpen(2) #move(30,95) #text("Other characters can be used in the production rules and initial") #move(10,115) #text("string. For example, the production rules for the dragon curve are:") #move(70,145) #text("X = X+YF+") #move(70,165) #text("Y = -FX-Y") #move(30,195) #text("The run statement is #run(X). The X and Y are expanded as normal,") #move(30,215) #text("but are ignored in the final string.") #move(30,275) #text("The following screen shows successive expansions of the initial string") #move(10,295) #text("(X) from no expansion to 3 expansions. The turning angle is 90.") #wait(180) #cls(1) #setpen(2) F= #move(8,60) #text("Level String Result") #set_heading(90) #set_length(600) #move(8,64) #run(F) #set_heading(0) #move(50,500) #run(F) #move(360,500) #run(F) #move(18,140) #text("0") #move(60,140) #text("X") #move(18,220) #text("1") #move(60,220) #text("X+YF+") #move(18,300) #text("2") #move(60,300) #text("X+YF+-FX-YF+") #move(18,380) #text("3") #move(60,380) #text("X+YF++-FX-YF+-FX+YF+--FX-YF+") #setpen(7) #set_angle(90) #move(400,140) X=X+YF+ Y=-FX-Y #set_heading(0) #set_length(80) #set_level(0) #run(X) #move(400,220) #set_length(80) #set_level(1) #run(X) #move(480,300) #set_length(40) #set_level(2) #run(X) #move(400,380) #set_length(20) #set_level(3) #run(X) #wait(180) #cls(1) #setpen(2) #move(30,80) #text("Level 8:") #move(30,82) #text("________") #setpen(5) #move(380,340) #set_length(8) #set_level(11) #run(X) #wait(180) #cls(1) #setpen(2) #move(30,80) #text("That's about it. The run files, such as this file and the demo file") #move(10,100) #text("can be created or edited using a text editor, which can be invoked") #move(10,120) #text("by selecting the Files/Edit menu.") #move(30,150) #text("To rerun this tutorial, choose the Files/Rerun menu.") #move(30,180) #text("To run another file, choose the Files/Run menu.") #move(30,210) #text("To quit, choose the Project/Quit menu.") #move(300,256) #text("**END**")