本文整理汇总了Python中turtle.Turtle.pencolor方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.pencolor方法的具体用法?Python Turtle.pencolor怎么用?Python Turtle.pencolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.pencolor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def main():
t = Turtle()
# prompt the user for the number of steps
iterations = input("Enter the number of reps: ")
t.pencolor("red")
t.screen.bgcolor("blue")
t.width(10)
# run the walk with the parameters specified
# this walk starts at the origin (centre of the window) every time
randomWalkRandomColours(t, 0, 0, iterations)
t.hideturtle()
print '\n\nProgram Done!'
示例2: setup
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def setup(color, distance):
t = Turtle()
t.pencolor(color)
t.penup()
t.forward(distance)
t.pendown()
return t
示例3: init
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def init():
global TTiles, STiles, designer
screen.mode("logo")
screen.tracer(False)
designer = Turtle(visible=False)
designer.pu()
makerhomboidshapes()
screen.bgcolor("gray10")
STiles = [TStein(A/20., clickable=False),
TStein(A/20., clickable=False),
TStein(2*d/20., clickable=False),
TStein(A/40., clickable=False),
TStein(A/40., clickable=False),
TStein(d/20., "square", clickable=False),
TRhomboid(clickable=False)]
TTiles = [TStein(A/20.),
TStein(A/20.),
TStein(2*d/20.),
TStein(A/40.),
TStein(A/40.),
TStein(d/20., "square"),
TRhomboid()]
for s in STiles:
s.color((1,1,0.9))
s.turtlesize(s.size, s.size, 2)
s.ht()
screen.update()
designer.goto(-390,-288)
designer.pencolor("gray70")
designer.write("Inspired by Pavel Boytchev's Elica-Logo implementation of the tangram game",
font=("Courier", 10, "bold"))
nextBtn = Button("next.gif", resetgame)
nextBtn.setpos(320,220)
helpBtn = Button("help.gif", helpme)
helpBtn.setpos(320,-220)
示例4: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def main():
"""Render a trio of trees"""
my_turtle = Turtle()
my_turtle.hideturtle()
my_turtle.speed(0)
my_turtle.home()
## a big tree
my_tree = Tree()
my_turtle.pencolor("brown")
my_turtle.pensize(4)
my_tree.draw(my_turtle, trunk=100, max_depth=5)
# draw over in another color
my_turtle.pencolor("green")
my_turtle.pensize(1)
my_tree.draw(my_turtle)
## a slightly smaller tree
my_turtle.penup()
my_turtle.goto(175, 30)
my_tree = Tree()
my_tree.draw(my_turtle, trunk=80, max_depth=4)
## a Charlie Brown tree
my_turtle.penup()
my_turtle.goto(-150, 40)
my_tree = Tree()
my_tree.draw(my_turtle, trunk=40, max_depth=2)
my_turtle.penup()
my_turtle.goto(0, -50)
my_turtle.write("Click in window to close")
示例5: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def main():
"""This is run only when F5 is pressed from IDLE or when
this file is run as a script in a terminal window."""
t = Turtle()
t.hideturtle()
t.speed(0)
t.pencolor("blue")
示例6: draw_line
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def draw_line(t: Turtle, start, end,*,
color="white", size=1):
t.pensize(size)
t.pencolor(color)
t.penup()
t.goto(*start)
t.pendown()
t.goto(*end)
示例7: test_redraw
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def test_redraw(self):
"""Verify that the tree draws over itself by using different pen sizes"""
my_turtle = Turtle()
my_turtle.pensize(5)
my_turtle.pencolor("black")
my_tree = Tree()
self.assertIsNone(my_tree.draw(my_turtle, max_depth=2), "Drawing a fresh tree should return None")
my_turtle.pensize(2)
my_turtle.pencolor("white")
self.assertIsNone(my_tree.draw(my_turtle), "Redrawing a tree should return None")
示例8: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def main():
t = Turtle()
# promp user for number of steps in the walk
iterations = int(input("Enter the number of reps: "))
t.pencolor("red")
t.screen.bgcolor("black")
# run the walk with the parameters specified
# this walk starts at the origin (centre of the window) every time
selfAvoidingWalk_randomDist(t, 0, 0, iterations)
t.hideturtle()
print '\n\nProgram Done!'
示例9: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def main():
t = Turtle()
# prompt user for all inputs
x = input("Enter the x-coordinate of the starting point: ")
y = input("Enter the y-coordinare of the starting point: ")
iterations = input("Enter the number of reps: ")
t.pencolor("red")
t.screen.bgcolor("black")
# run the walk with the parameters specified
randomWalk(t, x, y, iterations)
print '\n\nProgram Done!'
示例10: Raptor
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
class Raptor(object):
def __init__(self, distance, color, speed):
self.turtle = Turtle()
self.speed = speed
self.turtle.pencolor(color)
self.turtle.penup()
self.turtle.forward(distance)
self.turtle.pendown()
def move(self, target):
angle = self.turtle.towards(target)
self.turtle.setheading(angle)
self.turtle.forward(self.speed)
示例11: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def main():
t = Turtle()
# prompt for user inputs
iterations = int(input("Enter the number of reps: "))
length = int(input("Enter the distance travelled for each step: "))
t.pencolor("red")
t.screen.bgcolor("black")
# run the walk with the parameters specified
# this walk starts at the origin (centre of the window) every time
selfAvoidingWalk(t, 0, 0, iterations, length)
t.hideturtle()
print '\n\nProgram Done!'
示例12: maketree
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def maketree():
p = Turtle()
p.pencolor("#697C82")
p.setundobuffer(None)
p.hideturtle()
p.speed(0)
p.tracer(30, 0)
p.left(90)
p.penup()
p.forward(-210)
p.pendown()
t = tree([p], 200, 65, 0.6375)
for x in t:
pass
示例13: Duckbill
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
class Duckbill(object):
def __init__(self, distance, color, speed, angle):
self.turtle = Turtle()
self.turtle.pencolor(color)
self.speed = speed
self.angle = angle
self.turtle.penup()
self.turtle.forward(distance)
self.turtle.pendown()
self.turtle.left(90)
def move(self):
self.turtle.forward(self.speed)
self.turtle.left(self.angle)
示例14: drawLevy
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
def drawLevy(n):
'draws nth Levy curve using instructions obtained from function levy()'
directions = levy(n)
t = Turtle()
bgcolor('black')
t.pencolor('yellow')
t.penup()
t.goto(-300,0)
t.pendown()
t.pensize(2)
for move in directions:
if move == 'F':
t.fd(200/math.sqrt(2)**n)
if move == 'L':
t.lt(45)
if move == 'R':
t.rt(90)
示例15: Body
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pencolor [as 别名]
class Body(object):
def __init__(self, name, pos, vel, mass, color, scaling):
self.name = name
self.pos = pos
self.vel = vel
self.mass = mass
self.scaling = scaling
self.turtle = Turtle()
self.turtle.speed("fastest")
self.turtle.pencolor(color)
self.turtle.penup()
self.move()
self.turtle.pendown()
def move(self):
x = self.pos.x * self.scaling
y = self.pos.y * self.scaling
self.turtle.goto((x, y))