MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / speed

Method speed

tools/python-3.11.9-amd64/Lib/turtle.py:2139–2175  ·  view source on GitHub ↗

Return or set the turtle's speed. Optional argument: speed -- an integer in the range 0..10 or a speedstring (see below) Set the turtle's speed to an integer value in the range 0 .. 10. If no argument is given: return current speed. If input is a n

(self, speed=None)

Source from the content-addressed store, hash-verified

2137 return self._drawing
2138
2139 def speed(self, speed=None):
2140 """ Return or set the turtle's speed.
2141
2142 Optional argument:
2143 speed -- an integer in the range 0..10 or a speedstring (see below)
2144
2145 Set the turtle's speed to an integer value in the range 0 .. 10.
2146 If no argument is given: return current speed.
2147
2148 If input is a number greater than 10 or smaller than 0.5,
2149 speed is set to 0.
2150 Speedstrings are mapped to speedvalues in the following way:
2151 'fastest' : 0
2152 'fast' : 10
2153 'normal' : 6
2154 'slow' : 3
2155 'slowest' : 1
2156 speeds from 1 to 10 enforce increasingly faster animation of
2157 line drawing and turtle turning.
2158
2159 Attention:
2160 speed = 0 : *no* animation takes place. forward/back makes turtle jump
2161 and likewise left/right make the turtle turn instantly.
2162
2163 Example (for a Turtle instance named turtle):
2164 >>> turtle.speed(3)
2165 """
2166 speeds = {'fastest':0, 'fast':10, 'normal':6, 'slow':3, 'slowest':1 }
2167 if speed is None:
2168 return self._speed
2169 if speed in speeds:
2170 speed = speeds[speed]
2171 elif 0.5 < speed < 10.5:
2172 speed = int(round(speed))
2173 else:
2174 speed = 0
2175 self.pen(speed=speed)
2176
2177 def color(self, *args):
2178 """Return or set the pencolor and fillcolor.

Callers 1

demo2Function · 0.45

Calls 1

penMethod · 0.95

Tested by

no test coverage detected