本文整理汇总了Python中turtle.Turtle.color方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.color方法的具体用法?Python Turtle.color怎么用?Python Turtle.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.color方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Lampe
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
class Lampe():
lyser = False
turtle = None
def lag_skilpadde(self):
""" Lager en egen skilpadde for denne lamen."""
self.turtle = Turtle()
self.turtle.penup()
self.turtle.hideturtle()
# Gult lys når vi lyser.
self.turtle.shape('circle')
self.turtle.color('yellow')
self.turtle.shapesize(5)
def slaa_paa(self):
self.lyser = True
self.turtle.showturtle()
def slaa_av(self):
self.lyser = False
self.turtle.hideturtle()
示例2: init_drawman
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
def init_drawman():
''' Инициализация черепашки '''
global t, x_current, y_current, _drawman_scale
shag=50
vod=0.5
t = Turtle()
t.penup()
x_current = 0
y_current = 0
t.goto(x_current, y_current)
drawman_scale(shag,vod)
t.penup()
t.goto(-300,250)
t.color("red")
y=-250
x=-300
while x<=300:
t.pendown()
t.goto(x,-250)
t.penup()
x+=shag
t.goto(x,250)
t.goto(300,250)
y=250
x=300
while y>=-250:
t.pendown()
t.goto(-300,y)
t.penup()
y-=shag
t.goto(300,y)
示例3: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
def main():
p = Turtle()
p.color("green")
p.pensize(3)
#p.setundobuffer(None)
p.hideturtle() #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.
#p.speed(10)
# p.getscreen().tracer(1,0)#Return the TurtleScreen object the turtle is drawing on.
p.speed(10)
#TurtleScreen methods can then be called for that object.
p.left(90)# Turn turtle left by angle units. direction 调整画笔
p.penup() #Pull the pen up – no drawing when moving.
p.goto(0, -80)#Move turtle to an absolute position. If the pen is down, draw line. Do not change the turtle’s orientation.
p.pendown()# Pull the pen down – drawing when moving. 这三条语句是一个组合相当于先把笔收起来再移动到指定位置,再把笔放下开始画
#否则turtle一移动就会自动的把线画出来
#t = tree([p], 200, 65, 0.6375)
t = tree([p], 200, 65, 0.6375)
p.penup() #Pull the pen up – no drawing when moving.
p.home()
p.goto(0, 80)
p.pendown()# P
p.right(90);
t1 = tree([p], 200, 65, 0.6375)
示例4: draw_loop
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
def draw_loop(turtle: Turtle, side: int, angle: int) -> None:
colors = ['red', 'green', 'blue', 'purple']
a = 0
while True:
turtle.left(angle % 24)
turtle.forward(side)
angle += 1
a += 1
turtle.color(colors[a % len(colors)])
示例5: maketree
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
def maketree(x, y):
p = Turtle()
p.color("green")
p.pensize(5)
p.hideturtle()
#p.getscreen().tracer(30)
p.speed(10)
p.left(90)
p.penup()
p.goto(x, y)
p.pendown()
t = tree([p], 110, 65, 0.6375)
示例6: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
def main():
side = float(input('Enter a side length: '))
turtle = Turtle()
turtle.penup()
turtle.setx(-side / 2)
turtle.sety(side / 2)
turtle.pendown()
turtle.speed('slowest')
turtle.color('green')
turtle.pensize(5)
for i in range(4):
turtle.forward(side)
turtle.right(90)
done()
示例7: draw_art
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
def draw_art():
window = Screen()
window.bgcolor('cyan')
angie = Turtle()
angie.shape('turtle')
angie.color('blue')
angie.speed(2000)
# angie.left(105)
for j in range(80):
angie.right(5)
draw_rhombus(angie, 100)
angie.left(90)
angie.forward(300)
# Close window
window.exitonclick()
示例8: draw_telerik_logo
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
def draw_telerik_logo(turtle: Turtle, side: int) -> None:
turtle.color('green')
turtle.penup()
turtle.setpos(-side * 1.5, side)
turtle.pendown()
turtle.left(45)
turtle.forward(side)
turtle.right(90)
turtle.forward(side * 2)
turtle.right(90)
for _ in range(2):
turtle.forward(side)
turtle.right(90)
turtle.forward(side * 2)
turtle.right(90)
turtle.forward(side)
示例9: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [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()
示例10: draw_olympics_logo
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [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
示例11: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
class Politician:
def __init__(self, x, y):
self.x = x
self.y = y
self.turtle = Turtle()
self.turtle.color('black')
self.turtle.penup()
self.turtle.goto(x, y)
self.turtle.pendown()
self.votes = 0
self.wins = 0
def readjust_after_election(self, win, winner):
if win == True:
self.turtle.color('green')
else:
self.turtle.color('red')
self.x = winner.x*0.5 + self.x*0.5
self.y = winner.y*0.5 + self.y*0.5
self.turtle.goto(self.x, self.y)
示例12: Material
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
class Material(object):
def __init__(self):
self.gods_hand = Turtle()
self.gods_hand.hideturtle()
self.gods_hand.speed(0)
def draw_line(self):
self.gods_hand.penup()
self.gods_hand.tracer(0, 0)
self.gods_hand.goto(100, 100)
self.gods_hand.pendown()
self.gods_hand.fill(True)
self.gods_hand.setheading(0)
self.gods_hand.forward(50)
self.gods_hand.setheading(90)
self.gods_hand.forward(50)
self.gods_hand.setheading(180)
self.gods_hand.forward(50)
self.gods_hand.setheading(270)
self.gods_hand.forward(50)
self.gods_hand.fill(False)
self.gods_hand.penup()
self.gods_hand.goto(120, 120)
self.gods_hand.pendown()
self.gods_hand.pencolor("Blue")
self.gods_hand.fillcolor("Blue")
self.gods_hand.fill(True)
self.gods_hand.setheading(0)
self.gods_hand.forward(10)
self.gods_hand.setheading(90)
self.gods_hand.forward(10)
self.gods_hand.setheading(180)
self.gods_hand.forward(10)
self.gods_hand.setheading(270)
self.gods_hand.forward(10)
self.gods_hand.fill(False)
self.gods_hand.penup()
self.gods_hand.tracer(1, 1)
def build_box(self, pos_x, pos_y, length_x, length_y, do_fill, color):
pos_x, pos_y = coordinate_converter((pos_x, pos_y))
self.gods_hand.tracer(0, 0)
self.gods_hand.penup()
self.gods_hand.goto(pos_x, pos_y)
self.gods_hand.pendown()
if do_fill:
self.gods_hand.fill(True)
self.gods_hand.color(color)
for x in range(4, 0, -1):
heading = x * 90
self.gods_hand.setheading(heading)
self.gods_hand.forward(length_x)
if do_fill:
self.gods_hand.fill(False)
self.gods_hand.tracer(1, 1)
def draw_human(self, pos_x, pos_y):
self.gods_hand.tracer(0, 0)
self.gods_hand.penup()
self.gods_hand.goto(pos_x, pos_y)
self.gods_hand.color("blue")
self.gods_hand.shape("circle")
self.gods_hand.shapesize(0, 0, 5)
stampid = self.gods_hand.stamp()
self.gods_hand.color("black")
self.gods_hand.tracer(1, 1)
return stampid
def erase_human(self, stampid):
self.gods_hand.clearstamp(stampid)
示例13: Screen
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
bot.color("green");
bot.speed("slowest");
#bot.setpos(x, y)
#bot.st()
bot.circle(50);
bot.clear()
window = Screen();
window.bgcolor("yellow");
#draw_triangle(3, 100, 100)
#draw_square(4, 200, 200)
#draw_circle(300, 300)
# 1. don't show trutle shape.
# 2. we need to draw multiple squres (360/10 = 36 squares)
# 3. each squre we should start with different angle (10 degrees).
# 4. for each square, createa turtle and call square function.
bot = Turtle()
#bot.ht()
bot.color("blue", "green");
bot.speed("fast");
bot.begin_fill()
for i in range(0, 36):
print (" square " + str(i * 10))
draw_triangle(bot, 10)
bot.end_fill()
window.exitonclick()
示例14: Turtle
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
from turtle import Turtle
from random import random,choice
usr = Turtle()
usr.pensize(5)
usr.speed(0)
colors = [
'red',
'orange',
'yellow',
'green',
'blue',
'violet',
'gold',
'black',
]
def random_color():
return (random(),random(),random())
while True:
for count in range(4):
usr.forward(100)
usr.right(90)
usr.right(5)
usr.color(random_color())
示例15: Turtle
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import color [as 别名]
screenMinX = -screen.window_width() / 2
screenMinY = -screen.window_height() / 2
screenMaxX = screen.window_width() / 2
screenMaxY = screen.window_height() / 2
screen.setworldcoordinates(screenMinX, screenMinY, screenMaxX, screenMaxY)
screen.bgcolor("black")
offscreen_x = screenMinX - 100
t = Turtle()
t.penup()
t.ht()
t.speed(0)
t.goto(0, screenMaxY - 20)
t.color('grey')
t.write("Turtles in Space!!", align="center", font=("Arial", 20))
t.goto(0, screenMaxY - 33)
t.write("Use the arrow keys to move, 'x' to fire, 'q' to quit", align="center")
t.goto(0, 0)
t.color("red")
class Bullet(Turtle):
def __init__(self, screen, x, y, heading):
super().__init__()
self.speed(0)
self.penup()
self.goto(x, y)
self.seth(heading)
self.screen = screen