本文整理汇总了Python中turtle.Turtle.pensize方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.pensize方法的具体用法?Python Turtle.pensize怎么用?Python Turtle.pensize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.pensize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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")
示例2: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [as 别名]
def main():
screen.mode("logo")
t = Turtle(shape="triangle")
t.penup(); t.back(280); t.pendown()
t.pensize(3)
itree(t, 250, 0.63,
["black", "brown", "red", "orange", "violet", "lightblue"])
示例3: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [as 别名]
def main():
dimension = int(input('Enter dimension: '))
t = Turtle()
t.speed('fastest')
t.pensize(3)
draw_table(dimension, 50, t, -200, 300)
示例5: draw_line
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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)
示例6: test_redraw
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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")
示例7: maketree
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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)
示例8: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [as 别名]
def main():
t = Turtle()
t.speed('fast')
t.pensize(10)
draw_loop(t, 20, 10)
t.clear()
draw_olympics_logo(t, 50)
t.clear()
draw_telerik_logo(t, 200)
done()
示例9: drawLevy
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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)
示例10: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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()
示例11: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [as 别名]
def main():
s = Screen()
s.bgcolor("black")
p=Turtle()
p.speed(0)
p.hideturtle()
p.pencolor("red")
p.pensize(3)
s.tracer(36,0)
at = clock()
mn_eck(p, 36, 19)
et = clock()
z1 = et-at
sleep(1)
at = clock()
while any([t.undobufferentries() for t in s.turtles()]):
for t in s.turtles():
t.undo()
et = clock()
return "Laufzeit: {0:.3f} sec".format(z1+et-at)
示例12: main
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [as 别名]
def main():
s = Screen()
s.bgcolor("black")
p=Turtle()
p.speed(0)
p.hideturtle()
p.pencolor("red")
p.pensize(3)
s.tracer(36,0)
at = clock()
mn_eck(p, 36, 19)
et = clock()
z1 = et-at
sleep(1)
at = clock()
while any(t.undobufferentries() for t in s.turtles()):
for t in s.turtles():
t.undo()
et = clock()
return "runtime: %.3f sec" % (z1+et-at)
示例13: saovar
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [as 别名]
def saovar():
acolor=input('Asuna pen color?')
asize=input('Asuna pensize?')
asuna = Turtle()
asuna.pensize(asize)
asuna.pencolor(acolor)
kicolor=input('Kirito pen color?')
kisize=input('Kirito pensize?')
kirito = Turtle()
kirito.pensize(kisize)
kirito.pencolor(kicolor)
klcolor=input('Klein pen color?')
klsize=input('Klein pensize?')
klein = Turtle()
klein.pensize(klsize)
klein.pencolor(klcolor)
示例14: Turtle
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [as 别名]
from turtle import Turtle
p = Turtle()
p.speed(3)
p.pensize(5)
p.color("black", 'yellow')
p.begin_fill()
for i in range(5):
p.forward(200)
p.right(144)
p.end_fill()
示例15: __init__
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import pensize [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()