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


Python turtle.begin_fill方法代码示例

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


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

示例1: square

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def square(x, y, size, name):
    """Draw square at `(x, y)` with side length `size` and fill color `name`.

    The square is oriented so the bottom left corner is at (x, y).

    """
    import turtle
    turtle.up()
    turtle.goto(x, y)
    turtle.down()
    turtle.color(name)
    turtle.begin_fill()

    for count in range(4):
        turtle.forward(size)
        turtle.left(90)

    turtle.end_fill() 
开发者ID:PacktPublishing,项目名称:Learning-Python-by-building-games,代码行数:20,代码来源:base.py

示例2: head

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def head():
    '''
    头
    '''
    t.color((255, 155, 192), "pink")
    t.pu()
    t.seth(90)
    t.fd(41)
    t.seth(0)
    t.fd(0)
    t.pd()
    t.begin_fill()
    t.seth(180)
    t.circle(300, -30)  # 顺时针画一个半径为300,圆心角为30°的园
    t.circle(100, -60)
    t.circle(80, -100)
    t.circle(150, -20)
    t.circle(60, -95)
    t.seth(161)
    t.circle(-300, 15)
    t.pu()
    t.goto(-100, 100)
    t.pd()
    t.seth(-30)
    a = 0.4
    for i in range(60):
        if 0 <= i < 30 or 60 <= i < 90:
            a = a + 0.08
            t.lt(3)  # 向左转3度
            t.fd(a)  # 向前走a的步长
        else:
            a = a - 0.08
            t.lt(3)
            t.fd(a)
    t.end_fill() 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:37,代码来源:xzpq.py

示例3: draw_leaf

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def draw_leaf(turtle):
    turtle.fillcolor("greenyellow")
    turtle.begin_fill()
    
    base = turtle.pos()
    turtle.circle(100,75)
    turtle.goto(base)
    turtle.circle(-100,75)
    turtle.goto(base)
    turtle.end_fill() 
开发者ID:remon,项目名称:pythonCodes,代码行数:12,代码来源:My_Pink_Flower_en.py

示例4: ear

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def ear():
    '''
    耳朵
    '''
    t.color((255, 155, 192), "pink")
    t.pu()
    t.seth(90)
    t.fd(-7)
    t.seth(0)
    t.fd(70)
    t.pd()
    t.begin_fill()
    t.seth(100)
    t.circle(-50, 50)
    t.circle(-10, 120)
    t.circle(-50, 54)
    t.end_fill()
    t.pu()
    t.seth(90)
    t.fd(-12)
    t.seth(0)
    t.fd(30)
    t.pd()
    t.begin_fill()
    t.seth(100)
    t.circle(-50, 50)
    t.circle(-10, 120)
    t.circle(-50, 56)
    t.end_fill() 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:31,代码来源:xzpq.py

示例5: run_instruction

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def run_instruction(t):
    if t.data == 'change_color':
        turtle.color(*t.children)   # We just pass the color names as-is

    elif t.data == 'movement':
        name, number = t.children
        { 'f': turtle.fd,
          'b': turtle.bk,
          'l': turtle.lt,
          'r': turtle.rt, }[name](int(number))

    elif t.data == 'repeat':
        count, block = t.children
        for i in range(int(count)):
            run_instruction(block)

    elif t.data == 'fill':
        turtle.begin_fill()
        run_instruction(t.children[0])
        turtle.end_fill()

    elif t.data == 'code_block':
        for cmd in t.children:
            run_instruction(cmd)
    else:
        raise SyntaxError('Unknown instruction: %s' % t.data) 
开发者ID:lark-parser,项目名称:lark,代码行数:28,代码来源:turtle_dsl.py

示例6: blusher

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def blusher():
    '''
    腮
    '''
    t.color((255, 155, 192))
    t.pu()
    t.seth(90)
    t.fd(-95)
    t.seth(0)
    t.fd(65)
    t.pd()
    t.begin_fill()
    t.circle(30)
    t.end_fill() 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:16,代码来源:xzpq.py

示例7: s

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def s(n, l):

    if n == 0: # stop conditions

        # draw filled rectangle

        turtle.color('black')
        turtle.begin_fill()
        for _ in range (4):
            turtle.forward(l)
            turtle.left(90)
        turtle.end_fill()

    else: # recursion

        # around center point create 8 smalles rectangles.
        # create two rectangles on every side 
        # so you have to repeat it four times

        for _ in range(4):
            # first rectangle
            s(n-1, l/3)    
            turtle.forward(l/3)

            # second rectangle
            s(n-1, l/3)    
            turtle.forward(l/3)

            # go to next corner
            turtle.forward(l/3)
            turtle.left(90)
            
        # update screen
        turtle.update()

# --- main ---    

# stop updating screen (to make it faster) 
开发者ID:furas,项目名称:python-examples,代码行数:40,代码来源:main.py

示例8: hexagone

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def hexagone(point, longueur,c):
   l = longueur

   x, y = point

   turtle.up()
   turtle.goto(point)
   turtle.color(c[0]) #black
   turtle.down()
   turtle.begin_fill() 
   turtle.goto(l * cos(4 / 3 * pi )+x, l * sin(4 / 3 * pi)+y)
   turtle.goto(l * cos(5 / 3 * pi)+x, l * sin(5 / 3 * pi)+y)
   turtle.goto(l * cos(0)+x, l * sin(0)+y) 
   turtle.goto(point) 
   turtle.end_fill()

   turtle.color(c[1])  #blue
   turtle.begin_fill()
   turtle.goto(l * cos(0)+x, l * sin(0)+y) 
   turtle.goto(l * cos(pi / 3)+x, l * sin(pi / 3)+y)
   turtle.goto(l * cos(pi * 2 / 3)+x, l * sin(pi * 2 / 3)+y)
   turtle.goto(point)  
   turtle.end_fill()

   turtle.color(c[2]) #red
   turtle.begin_fill()
   turtle.goto(l * cos(pi * 2 / 3)+x, l * sin(pi * 2 / 3)+y)
   turtle.goto(-l+x, 0+y)
   turtle.goto(l * cos(4 / 3 * pi)+x, l * sin(4 / 3 * pi)+y)
   turtle.goto(point)
   turtle.end_fill()
   turtle.up()

   return True 
开发者ID:furas,项目名称:python-examples,代码行数:36,代码来源:main.py

示例9: norse

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def norse():
    '''
    鼻子
    '''
    t.pu()  # 提笔
    t.goto(-100, 100)  # 画笔前往坐标(-100,100)
    t.pd()  # 下笔
    t.seth(-30)  # 笔的角度为-30°
    t.begin_fill()  # 外形填充的开始标志
    a = 0.4
    for i in range(120):
        if 0 <= i < 30 or 60 <= i < 90:
            a = a + 0.08
            t.lt(3)  # 向左转3度
            t.fd(a)  # 向前走a的步长
        else:
            a = a - 0.08
            t.lt(3)
            t.fd(a)
    t.end_fill()  # 依据轮廓填充
    t.pu()  # 提笔
    t.seth(90)  # 笔的角度为90度
    t.fd(25)  # 向前移动25
    t.seth(0)  # 转换画笔的角度为0
    t.fd(10)
    t.pd()
    t.pencolor(255, 155, 192)  # 设置画笔颜色
    t.seth(10)
    t.begin_fill()
    t.circle(5)  # 画一个半径为5的圆
    t.color(160, 82, 45)  # 设置画笔和填充颜色
    t.end_fill()
    t.pu()
    t.seth(0)
    t.fd(20)
    t.pd()
    t.pencolor(255, 155, 192)
    t.seth(10)
    t.begin_fill()
    t.circle(5)
    t.color(160, 82, 45)
    t.end_fill() 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:44,代码来源:xzpq.py

示例10: eye

# 需要导入模块: import turtle [as 别名]
# 或者: from turtle import begin_fill [as 别名]
def eye():
    '''
    眼睛
    '''
    t.color((255, 155, 192), "white")
    t.pu()
    t.seth(90)
    t.fd(-20)
    t.seth(0)
    t.fd(-95)
    t.pd()
    t.begin_fill()
    t.circle(15)
    t.end_fill()
    t.color("black")
    t.pu()
    t.seth(90)
    t.fd(12)
    t.seth(0)
    t.fd(-3)
    t.pd()
    t.begin_fill()
    t.circle(3)
    t.end_fill()
    t.color((255, 155, 192), "white")
    t.pu()
    t.seth(90)
    t.fd(-25)
    t.seth(0)
    t.fd(40)
    t.pd()
    t.begin_fill()
    t.circle(15)
    t.end_fill()
    t.color("black")
    t.pu()
    t.seth(90)
    t.fd(12)
    t.seth(0)
    t.fd(-3)
    t.pd()
    t.begin_fill()
    t.circle(3)
    t.end_fill() 
开发者ID:MiracleYoung,项目名称:You-are-Pythonista,代码行数:46,代码来源:xzpq.py


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