MCPcopy Index your code
hub / github.com/python/cpython / tiltangle

Method tiltangle

Lib/turtle.py:2975–3009  ·  view source on GitHub ↗

Set or return the current tilt-angle. Optional argument: angle -- number Rotate the turtleshape to point in the direction specified by angle, regardless of its current tilt-angle. DO NOT change the turtle's heading (direction of movement). If angle is not gi

(self, angle=None)

Source from the content-addressed store, hash-verified

2973 self.pen(resizemode="user", shearfactor=shear)
2974
2975 def tiltangle(self, angle=None):
2976 """Set or return the current tilt-angle.
2977
2978 Optional argument: angle -- number
2979
2980 Rotate the turtleshape to point in the direction specified by angle,
2981 regardless of its current tilt-angle. DO NOT change the turtle's
2982 heading (direction of movement).
2983 If angle is not given: return the current tilt-angle, i. e. the angle
2984 between the orientation of the turtleshape and the heading of the
2985 turtle (its direction of movement).
2986
2987 Examples (for a Turtle instance named turtle):
2988 >>> turtle.shape("circle")
2989 >>> turtle.shapesize(5, 2)
2990 >>> turtle.tiltangle()
2991 0.0
2992 >>> turtle.tiltangle(45)
2993 >>> turtle.tiltangle()
2994 45.0
2995 >>> turtle.stamp()
2996 >>> turtle.fd(50)
2997 >>> turtle.tiltangle(-45)
2998 >>> turtle.tiltangle()
2999 315.0
3000 >>> turtle.stamp()
3001 >>> turtle.fd(50)
3002 """
3003 if angle is None:
3004 tilt = -math.degrees(self._tilt) * self._angleOrient
3005 return (tilt / self._degreesPerAU) % self._fullcircle
3006 else:
3007 tilt = -angle * self._degreesPerAU * self._angleOrient
3008 tilt = math.radians(tilt) % math.tau
3009 self.pen(resizemode="user", tilt=tilt)
3010
3011 def tilt(self, angle):
3012 """Rotate the turtleshape by angle.

Callers 1

tiltMethod · 0.95

Calls 3

degreesMethod · 0.80
radiansMethod · 0.80
penMethod · 0.80

Tested by

no test coverage detected