当前位置: 首页>>代码示例>>Python>>正文


Python Turtle.color方法代码示例

本文整理汇总了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()
开发者ID:Arxcis,项目名称:Python-V2016,代码行数:28,代码来源:LysAvogpaa.py

示例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)
开发者ID:SafonovaO,项目名称:StudentFox,代码行数:37,代码来源:drawman101.py

示例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)
开发者ID:allensdz,项目名称:python,代码行数:28,代码来源:DrawTree.py

示例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)])
开发者ID:wencakisa,项目名称:Softuni-Python3,代码行数:12,代码来源:drawing_loop.py

示例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)
开发者ID:944624574ws,项目名称:python,代码行数:14,代码来源:tree.py

示例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()
开发者ID:wencakisa,项目名称:Softuni-Python3,代码行数:19,代码来源:square.py

示例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()
开发者ID:andela-rekemezie,项目名称:python-collections,代码行数:20,代码来源:draw_rhombus.py

示例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)
开发者ID:wencakisa,项目名称:Softuni-Python3,代码行数:22,代码来源:drawing_loop.py

示例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()
开发者ID:kunalprompt,项目名称:computerScienceFundamentals,代码行数:30,代码来源:playing_with_turtle.py

示例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
开发者ID:wencakisa,项目名称:Softuni-Python3,代码行数:24,代码来源:drawing_loop.py

示例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)
开发者ID:neylsoncrepalde,项目名称:MQ,代码行数:22,代码来源:politicians.py

示例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)
开发者ID:gorbyebrius,项目名称:utbildning,代码行数:80,代码来源:m2_world_emulator.py

示例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()
开发者ID:sirishagutha,项目名称:udacity,代码行数:32,代码来源:mindstroms.py

示例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())


开发者ID:whitman-colm,项目名称:archive,代码行数:29,代码来源:uhhh.py

示例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
开发者ID:mwoinoski,项目名称:crs1906,代码行数:33,代码来源:asteroids.py


注:本文中的turtle.Turtle.color方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。