本文整理汇总了Python中turtle.Turtle.stamp方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.stamp方法的具体用法?Python Turtle.stamp怎么用?Python Turtle.stamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类turtle.Turtle
的用法示例。
在下文中一共展示了Turtle.stamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Material
# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import stamp [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)