本文整理汇总了Python中turtle.Turtle.circle方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.circle方法的具体用法?Python Turtle.circle怎么用?Python Turtle.circle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.circle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
def main():
## create compound yellow/blue turtleshape for planets
global s
s = Screen()
s.setup(1120,840)
s.reset()
s.tracer(0, 0)
t = Turtle()
t.ht()
t.pu()
t.fd(6)
t.lt(90)
t.begin_poly()
t.circle(6, 180)
t.end_poly()
m1 = t.get_poly()
t.begin_poly()
t.circle(6,180)
t.end_poly()
m2 = t.get_poly()
planetshape = Shape("compound")
planetshape.addcomponent(m1,"orange")
planetshape.addcomponent(m2,"blue")
s.register_shape("planet", planetshape)
#s.tracer(1,0)
s.update()
## setup gravitational system
gs = GravSys()
sun = Star(1000000, Vec(-250,0), Vec(0,-0.35), gs, "circle")
sun.color("yellow")
sun.pensize(1.8)
sun.pu()
earth = Star(5000, Vec(450,0), Vec(0,70), gs, "planet")
earth.pencolor("green")
earth.shapesize(0.8)
rm=12.0583
vm=(8.0*5000/rm)**.5
moon = Star(1, Vec(450+rm,0), Vec(0,70+vm), gs, "planet")
moon.pencolor("blue")
moon.shapesize(0.5)
gs.init()
gs.start()
return "Done!"
示例2: createPlanetShape
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
def createPlanetShape():
s.tracer(0,0)
t = Turtle()
t.ht()
t.pu()
t.fd(6)
t.lt(90)
t.begin_poly()
t.circle(6, 180)
t.end_poly()
m1 = t.get_poly()
t.begin_poly()
t.circle(6,180)
t.end_poly()
m2 = t.get_poly()
planetshape = Shape("compound")
planetshape.addcomponent(m1,"orange")
planetshape.addcomponent(m2,"blue")
s.register_shape("planet", planetshape)
s.tracer(True,0)
示例3: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
def main():
# creating a window
window = Screen()
# window.bgcolor("orange")
remo = Turtle()
remo.shape("turtle")
remo.color("green")
remo.speed(50)
for i in range(36):
remo.circle(100)
remo.left(10)
remo.color("red")
for i in range(36):
remo.circle(80)
remo.left(10)
remo.color("yellow")
for i in range(36):
remo.circle(60)
remo.left(10)
window.exitonclick()
示例4: draw_olympics_logo
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
def draw_olympics_logo(turtle: Turtle, radius: int) -> None:
x_coord = -radius * 3
x_subtract = radius + 20
colors = ['blue', 'yellow', 'red', 'green', 'black']
for i in range(0, len(colors), 2):
turtle.penup()
turtle.setpos(x_coord, 0)
turtle.pendown()
turtle.color(colors[i])
turtle.circle(radius)
x_coord += x_subtract
if i + 1 != len(colors):
turtle.penup()
turtle.setpos(x_coord, -radius)
turtle.pendown()
turtle.color(colors[i + 1])
turtle.circle(radius)
x_coord += x_subtract
示例5: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
def main():
s = Turtle()
s.reset()
s.getscreen().tracer(0,0)
s.ht()
s.pu()
s.fd(6)
s.lt(90)
s.begin_poly()
s.circle(6, 180)
s.end_poly()
m1 = s.get_poly()
s.begin_poly()
s.circle(6,180)
s.end_poly()
m2 = s.get_poly()
planetshape = Shape("compound")
planetshape.addcomponent(m1,"orange")
planetshape.addcomponent(m2,"blue")
s.getscreen().register_shape("planet", planetshape)
s.getscreen().tracer(1,0)
## setup gravitational system
gs = GravSys()
sun = Star(1000000, Vec(0,0), Vec(0,-2.5), gs, "circle")
sun.color("yellow")
sun.shapesize(1.8)
sun.pu()
earth = Star(12500, Vec(210,0), Vec(0,195), gs, "planet")
earth.pencolor("green")
earth.shapesize(0.8)
moon = Star(1, Vec(220,0), Vec(0,295), gs, "planet")
moon.pencolor("blue")
moon.shapesize(0.5)
gs.init()
gs.start()
return "Done!"
示例6: Turtle
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
from turtle import Turtle
t = Turtle()
t.speed(0)
a = 180
b = 180
for i in range(100):
t.circle(i,a)
t.right(b)
t.circle(i,a)
t.right(b)
t.circle(i,a)
t.right(b)
t.circle(i,a)
input('Press any key to continue...')
示例7: ParsonTurtle
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
class ParsonTurtle(Turtle):
def __init__(self):
self._turtle = Turtle()
self._turtle.shape('turtle')
self._commands = []
def forward(self, dist, log=True):
self._turtle.forward(dist)
if log:
self._commands.append("fwd" + str(dist))
def fd(self, dist, log=True):
return self.forward(dist, log=log)
def backward(self, dist, log=True):
self._turtle.backward(dist)
if log:
self._commands.append("bwd" + str(dist))
def back(self, dist, log=True):
return self.backward(dist, log=log)
def bk(self, dist, log=True):
return self.backward(dist, log=log)
def left(self, angle, log=True):
self._turtle.left(angle)
if log:
self._commands.append("lt" + str(angle))
def lt(self, angle, log=True):
return self.left(angle, log=log)
def right(self, angle, log=True):
self._turtle.right(angle)
if log:
self._commands.append("rt" + str(angle))
def rt(self, angle, log=True):
return self.right(angle, log=log)
def goto(self, nx, ny, log=True):
self._turtle.goto(nx, ny)
if log:
self._commands.append("gt" + str(nx) + "-" + str(ny))
def setposition(self, nx, ny, log=True):
self._turtle.setposition(nx, ny)
if log:
self._commands.append("setpos" + str(nx) + "-" + str(ny))
def setpos(self, nx, ny, log=True):
return self.setposition(nx, ny, log=log)
def setx(self, nx, log=True):
self._turtle.setx(nx)
if log:
self._commands.append("setx" + str(nx))
def sety(self, ny, log=True):
self._turtle.sety(ny)
if log:
self._commands.append("sety" + str(ny))
def dot(self, size, color, log=True):
self._turtle.dot(size, color)
if log:
self._commands.append("dot" + str(size) + "-" + str(color))
def circle(self, radius, extent, log=True):
self._turtle.circle(radius, extent)
if log:
self._commands.append("circle" + str(radius) + "-" + str(extent))
def up(self, log=True):
self._turtle.up()
if log:
self._commands.append("up")
def penup(self, log=True):
return self.up(log=log)
def pu(self, log=True):
return self.up(log=log)
def down(self, log=True):
self._turtle.down()
if log:
self._commands.append("down")
def pendown(self, log=True):
return self.down(log=log)
def pd(self, log=True):
return self.down(log=log)
def speed(self, spd):
self._turtle.speed(spd)
def _logColorChange(self, command, color, green, blue):
if blue is not None:
self._commands.append("%s(%d, %d, %d)"%(command, color, green, blue))
else:
self._commands.append("%s(%s)"%(command, color))
def pencolor(self, color, green=None, blue=None, log=True):
if blue is not None:
self._turtle.pencolor(color, green, blue)
else:
#.........这里部分代码省略.........
示例8: Turtle
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
from turtle import Turtle
t = Turtle()
t.speed(0)
for x in range(50):
t.circle(3*x)
t.right(90)
for x in range(50):
t.circle(3*x)
t.right(90)
for x in range(50):
t.circle(3*x)
t.right(90)
for x in range(50):
t.circle(3*x)
input('Press any key to continue...')
示例9: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
class KeysMouseEvents:
def __init__(self):
super().__init__()
self.reinit()
def reinit(self):
self.T=Turtle()
self.screen=self.T.getscreen()
self.screen.onclick(self.drawcir)
self.screen.onkey(self.clear,"c")
self.T.pensize(5)
self.screen.listen()
self.count=0
self.firstx=0
self.firsty=0
self.secondx=0
self.secondy=0
self.T.hideturtle()
self.T.up()
def clear(self):
self.T.screen.clear()
self.reinit()
def drawcir(self,x,y):
self.count = (self.count + 1)
if self.count == 1:
self.T.color("black")
self.firstx=x
self.firsty=y
self.T.goto(x,y)
self.T.down()
self.T.dot()
self.T.up()
return
if self.count == 2:
self.secondx=x
self.secondy=y
X = self.secondx - self.firstx
Y = self.secondy - self.firsty
d = X * X + Y * Y
self.T.color("black")
radious = math.sqrt (d);
self.T.goto(self.firstx, self.firsty-radious)
self.T.down()
self.T.circle(radious)
self.T.up()
c = random.randint(1, 4)
if c == 1:
self.T.color("red")
if c == 2:
self.T.color("green")
if c == 3:
self.T.color("blue")
if c == 4:
self.T.color("yellow")
self.T.begin_fill()
radious=radious-4
self.T.goto(self.firstx, self.firsty-radious)
self.T.down()
self.T.circle(radious)
self.T.end_fill()
self.T.up()
self.T.color("black")
self.T.goto(self.firstx,self.firsty)
self.T.down()
self.T.dot()
self.T.up()
self.count=0
def main(self):
mainloop()
示例10: range
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
# Set the window background color to black
window.bgcolor("black")
# Make the cursor ink white, the width of the pen 3, the shape a turtle, and
# move at moderate speed
cursor.color("white")
cursor.width(3)
cursor.shape("turtle") # or "circle", "classic", etc.
cursor.speed(5) # 1 - 10
# Draw a square of side length 100 starting from the home position
cursor.home()
for i in range(4):
print cursor.position()
cursor.forward(100)
cursor.right(90)
print cursor.position()
# Move the turtle to (0, 100) without drawing anything,
# then draw a pentagon
cursor.penup()
cursor.sety(100)
print cursor.position()
cursor.pendown()
cursor.color("green")
cursor.circle(50, steps=5) # remove ", steps=5" to make a circle
# Keep the window open until you click to close it
window.exitonclick()
示例11: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import circle [as 别名]
#.........这里部分代码省略.........
if c == 5:
self.T.color("white")
if c == 6:
self.T.color("pink")
if c == 7:
self.T.color("brown")
if c == 8:
self.T.color("purple")
if c == 9:
self.T.color("gray")
if c == 10:
self.T.color("orange")
self.T.begin_fill()
radius1=radius-4
self.T.goto(self.firstx-radius1, self.firsty+radius1)
self.T.down()
width = 2*radius1
height = 2*radius1
self.T.speed(0)
self.T.forward(width)
self.T.right(90)
self.T.forward(height)
self.T.right(90)
self.T.forward(width)
self.T.right(90)
self.T.forward(height)
self.T.right(90)
self.T.up()
self.T.end_fill()
self.T.up()
self.T.color("black")
self.T.goto(self.firstx, self.firsty-radius)
self.T.down()
self.T.circle(radius)
self.T.up()
c = x+1
if c == 1:
self.T.color("red")
if c == 2:
self.T.color("green")
if c == 3:
self.T.color("blue")
if c == 4:
self.T.color("yellow")
if c == 5:
self.T.color("white")
if c == 6:
self.T.color("pink")
if c == 7:
self.T.color("brown")
if c == 8:
self.T.color("purple")
if c == 9:
self.T.color("gray")
if c == 10:
self.T.color("orange")
self.T.begin_fill()
radius=radius-4
self.T.goto(self.firstx, self.firsty-radius)
self.T.speed(0)
self.T.down()
self.T.circle(radius)
self.T.end_fill()
self.T.up()