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

Method circle

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

Draw a circle with given radius. Arguments: radius -- a number extent (optional) -- a number steps (optional) -- an integer Draw a circle with given radius. The center is radius units left of the turtle; extent - an angle - determines which

(self, radius, extent = None, steps = None)

Source from the content-addressed store, hash-verified

1937 self._rotate(angle)
1938
1939 def circle(self, radius, extent = None, steps = None):
1940 """ Draw a circle with given radius.
1941
1942 Arguments:
1943 radius -- a number
1944 extent (optional) -- a number
1945 steps (optional) -- an integer
1946
1947 Draw a circle with given radius. The center is radius units left
1948 of the turtle; extent - an angle - determines which part of the
1949 circle is drawn. If extent is not given, draw the entire circle.
1950 If extent is not a full circle, one endpoint of the arc is the
1951 current pen position. Draw the arc in counterclockwise direction
1952 if radius is positive, otherwise in clockwise direction. Finally
1953 the direction of the turtle is changed by the amount of extent.
1954
1955 As the circle is approximated by an inscribed regular polygon,
1956 steps determines the number of steps to use. If not given,
1957 it will be calculated automatically. Maybe used to draw regular
1958 polygons.
1959
1960 call: circle(radius) # full circle
1961 --or: circle(radius, extent) # arc
1962 --or: circle(radius, extent, steps)
1963 --or: circle(radius, steps=6) # 6-sided polygon
1964
1965 Example (for a Turtle instance named turtle):
1966 >>> turtle.circle(50)
1967 >>> turtle.circle(120, 180) # semicircle
1968 """
1969 if self.undobuffer:
1970 self.undobuffer.push(["seq"])
1971 self.undobuffer.cumulate = True
1972 speed = self.speed()
1973 if extent is None:
1974 extent = self._fullcircle
1975 if steps is None:
1976 frac = abs(extent)/self._fullcircle
1977 steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac)
1978 w = 1.0 * extent / steps
1979 w2 = 0.5 * w
1980 l = 2.0 * radius * math.sin(math.radians(w2)*self._degreesPerAU)
1981 if radius < 0:
1982 l, w, w2 = -l, -w, -w2
1983 tr = self._tracer()
1984 dl = self._delay()
1985 if speed == 0:
1986 self._tracer(0, 0)
1987 else:
1988 self.speed(0)
1989 self._rotate(w2)
1990 for i in range(steps):
1991 self.speed(speed)
1992 self._go(l)
1993 self.speed(0)
1994 self._rotate(w)
1995 self._rotate(-w2)
1996 if speed == 0:

Callers 1

mainFunction · 0.80

Calls 9

speedMethod · 0.95
_tracerMethod · 0.95
_delayMethod · 0.95
_rotateMethod · 0.95
_goMethod · 0.95
minFunction · 0.85
radiansMethod · 0.80
absFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected