當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。