#Turn turtle right by angle units. (Units are by default degrees, but can be set via the degrees() and radians() functions.) Angle orientation depends on the turtle mode, see mode().
CurrentAngle=CurrentAngle+angle
defleft(angle):
lt(angle)
deflt(angle):
globalCurrentAngle
#Turn turtle left by angle units. (Units are by default degrees, but can be set via the degrees() and radians() functions.) Angle orientation depends on the turtle mode, see mode().
CurrentAngle=CurrentAngle-angle
defgoto(x,y=None):
setposition(x,y=None)
defsetpos(x,y=None):
setposition(x,y=None)
defsetposition(x,y=None):
globalCurrentX,CurrentY,shape
#If y is None, x must be a pair of coordinates or a Vec2D (e.g. as returned by pos()).
# Move turtle to an absolute position. If the pen is down, draw line. Do not change the turtle’s orientation.
#Draw a circle with given radius. The center is radius units left of the turtle; extent – an angle – determines which part of the circle is drawn. If extent is not given, draw the entire circle. If extent is not a full circle, one endpoint of the arc is the current pen position. Draw the arc in counterclockwise direction if radius is positive, otherwise in clockwise direction. Finally the direction of the turtle is changed by the amount of extent.
print("Not yet in Laser turtle.")
'''
>>>turtle.home()
>>>turtle.position()
(0.00,0.00)
>>>turtle.heading()
0.0
>>>turtle.circle(50)
>>>turtle.position()
(-0.00,0.00)
>>>turtle.heading()
0.0
>>>turtle.circle(120,180)# draw a semicircle
>>>turtle.position()
(0.00,240.00)
>>>turtle.heading()
180.0
'''
defdot(size=None,*color):
#Draw a circular dot with diameter size, using color. If size is not given, the maximum of pensize+4 and 2*pensize is used.
#Stamp a copy of the turtle shape onto the canvas at the current turtle position. Return a stamp_id for that stamp, which can be used to delete it by calling clearstamp(stamp_id).
print("Not yet in Laser turtle.")
'''
>>>turtle.color("blue")
>>>turtle.stamp()
11
>>>turtle.fd(50)
'''
defclearstamp(stampid):
#Delete stamp with given stampid.
print("Not yet in Laser turtle.")
'''
>>>turtle.position()
(150.00,-0.00)
>>>turtle.color("blue")
>>>astamp=turtle.stamp()
>>>turtle.fd(50)
>>>turtle.position()
(200.00,-0.00)
>>>turtle.clearstamp(astamp)
>>>turtle.position()
(200.00,-0.00)
'''
defclearstamps(n=None):
#Delete all or first/last n of turtle’s stamps. If n is None, delete all stamps, if n > 0 delete first n stamps, else if n < 0 delete last n stamps.
print("Not yet in Laser turtle.")
'''
>>>foriinrange(8):
...turtle.stamp();turtle.fd(30)
13
14
15
16
17
18
19
20
>>>turtle.clearstamps(2)
>>>turtle.clearstamps(-2)
>>>turtle.clearstamps()
'''
defundo():
#Undo (repeatedly) the last turtle action(s). Number of available undo actions is determined by the size of the undobuffer.
print("Not yet in Laser turtle.")
'''
>>>foriinrange(4):
...turtle.fd(50);turtle.lt(80)
...
>>>foriinrange(8):
...turtle.undo()
'''
defspeed(speed=None):
#Set the turtle’s speed to an integer value in the range 0..10. If no argument is given, return current speed.
#Return the turtle’s current location (x,y) (as a Vec2D vector).
return(CurrentX,CurrentY)
deftowards(x,y=None):
#Return the angle between the line from turtle position to position specified by (x,y), the vector or the other turtle. This depends on the turtle’s start orientation which depends on the mode - “standard”/”world” or “logo”).
# Currently only toward an x,y point
xDiff=x-CurrentX
yDiff=y-CurrentY
returndegrees(atan2(yDiff,xDiff))
defxcor():
#Return the turtle’s x coordinate.
returnCurrentX
defycor():
#Return the turtle’s y coordinate.
returnCurrentY
defheading():
#Return the turtle’s current heading (value depends on the turtle mode, see mode())
returnCurrentAngle
defdistance(x,y=None):
#Return the distance from the turtle to (x,y), the given vector, or the given other turtle, in turtle step units.
dist=math.sqrt((x-CurrentY)**2+(y-CurrentY)**2)
returndist
defdegrees(fullcircle=360.0):
#Set angle measurement units, i.e. set number of “degrees” for a full circle. Default value is 360 degrees.
print("Not yet in Laser turtle.")
'''
>>>turtle.home()
>>>turtle.left(90)
>>>turtle.heading()
90.0
Changeanglemeasurementunittograd(alsoknownasgon,
grade,orgradianandequals1/100-thoftherightangle.)
>>>turtle.degrees(400.0)
>>>turtle.heading()
100.0
>>>turtle.degrees(360)
>>>turtle.heading()
90.0
'''
defradians():
#Set the angle measurement units to radians. Equivalent to degrees(2*math.pi).
print("Not yet in Laser turtle.")
'''
>>>turtle.home()
>>>turtle.left(90)
>>>turtle.heading()
90.0
>>>turtle.radians()
>>>turtle.heading()
1.5707963267948966
'''
defpendown():
down()
defpd():
down()
defdown():
globalCurrentColor
#Pull the pen down – drawing when moving.
CurrentColor=Color
defpenup():
up()
defpu():
up()
defup():
#Pull the pen up – no drawing when moving.
globalCurrentColor
CurrentColor=0
defpensize(width=None):
width(width=None)
defwidth(width=None):
#Set the line thickness to width or return it. If resizemode is set to “auto” and turtleshape is a polygon, that polygon is drawn with the same line thickness. If no argument is given, the current pensize is returned.
print("Not yet in Laser turtle.")
'''
>>>turtle.pensize()
1
>>>turtle.pensize(10)# from here on lines of width 10 are drawn
'''
defpen(pen=None,**pendict):
#Return or set the pen’s attributes in a “pen-dictionary” with the following key/value pairs:
#Fill the shape drawn after the last call to begin_fill().
print("Not yet in Laser turtle.")
defreset():
#Delete the turtle’s drawings from the screen, re-center the turtle and set variables to the default values.
globalshape
clear()
home()
defclear():
#Delete the turtle’s drawings from the screen. Do not move turtle. State and position of the turtle as well as drawings of other turtles are not affected.
#Make the turtle invisible. It’s a good idea to do this while you’re in the middle of doing some complex drawing, because hiding the turtle speeds up the drawing observably.
print("Not yet in Laser turtle.")
#>>> turtle.hideturtle()
defshowturtle():
st()
defst():
#Make the turtle visible.
print("Not yet in Laser turtle.")
defdelay(delay=None):
#Set or return the drawing delay in milliseconds. (This is approximately the time interval between two consecutive canvas updates.) The longer the drawing delay, the slower the animation.
print("Not yet in Laser turtle.")
'''
Optionalargument:
>>>screen.delay()
10
>>>screen.delay(5)
>>>screen.delay()
5
'''
defmainloop():
done()
defdone():
#Starts event loop - calling Tkinter’s mainloop function. Must be the last statement in a turtle graphics program. Must not be used if a script is run from within IDLE in -n mode (No subprocess) - for interactive use of turtle graphics.