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


Python Turtle.fill方法代码示例

本文整理汇总了Python中turtle.Turtle.fill方法的典型用法代码示例。如果您正苦于以下问题:Python Turtle.fill方法的具体用法?Python Turtle.fill怎么用?Python Turtle.fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在turtle.Turtle的用法示例。


在下文中一共展示了Turtle.fill方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Material

# 需要导入模块: from turtle import Turtle [as 别名]
# 或者: from turtle.Turtle import fill [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


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