python足球作画-LMLPHP

努力是为了不平庸~

学习的最大理由是想摆脱平庸,早一天就多一份人生的精彩;迟一天就多一天平庸的困扰。

python足球作画-LMLPHP

        那么,世界杯进行得如此火热,还有人不会画一个可可爱爱的足球吗?

那直接上代码肝他!

from turtle import *
import time
def set_start(x, y, w=0.5, c='black'):      #初始设置
    penup()  
    setx(x)  
    sety(y)  
    setheading(towards(0, 0))  
    width(w)  
    pencolor(c)  
    pendown()  
    speed(1000)
def fill_color_patch(x, y, c='white'):
    set_start(x, y, 1, c=c)
    forward(1)

def left_rotate(time, angle, length):
    for i in range(time):  
        left(angle)  
        forward(length)  

def right_rotate(time, angle, length):
    for i in range(time):  
        right(angle)  
        forward(length) 
def draw_football():
    fill_color_patch(39.34, -90.63)
    begin_fill()
    set_start(39.34, -90.63, w=2, c='black')
    setheading(124.2)
    left_rotate(20, 18, 12.2)
    goto(39.34, -90.63)
    fillcolor('#DCDCDC')
    end_fill()
    fill_color_patch(-25, -110)
    begin_fill()
    set_start(-25, -110, w=1, c='white')
    right_rotate(1, 160, 10)
    left_rotate(5, 20, 12)
    left_rotate(4, 18, 12)
    pencolor('black')
    left_rotate(1, 35, 12)
    left_rotate(7, 18, 12.1)
    goto(-25, -110)
    fillcolor('white')
    end_fill()
    fill_color_patch(-25, -108)
    begin_fill()
    set_start(-25, -108, w=1, c='black')
    right_rotate(1, 20, 4)
    right_rotate(2, 10, 3)
    left_rotate(1, 35, 5)
    left_rotate(1, 165, 5)
    right_rotate(2, 15, 3)
    goto(-25, -108)
    fillcolor('black')
    end_fill()
    fill_color_patch(-16, -101)
    begin_fill()
    set_start(-16, -101, w=1, c='black')
    right_rotate(1, 35, 8)
    right_rotate(1, 140, 4)
    left_rotate(2, 21, 2)
    left_rotate(2, 8, 4.5)
    right_rotate(1, 105, 8)
    right_rotate(1, 120, 3)
    left_rotate(3, 15, 4)
    goto(-16, -101)
    fillcolor('black')
    end_fill()
    fill_color_patch(-10, -93)
    begin_fill()
    set_start(-10, -93, w=1, c='black')
    left_rotate(1, 90, 4)
    right_rotate(1, 135, 5)
    right_rotate(2, 3, 7)
    right_rotate(1, 60, 3)
    right_rotate(1, 135, 5)
    left_rotate(3, 10, 4)
    goto(-10, -93)
    fillcolor('black')
    end_fill()
    fill_color_patch(6, -82)
    begin_fill()
    set_start(6, -82, w=1, c='black')
    right_rotate(1, 50, 4)
    right_rotate(1, 60, 6)
    right_rotate(2, 3, 7)
    right_rotate(1, 130, 4)
    right_rotate(1, 60, 5)
    left_rotate(3, 8, 4)
    goto(6, -82)
    fillcolor('black')
    end_fill()
    fill_color_patch(30, -88)
    begin_fill()
    set_start(30, -88, w=1, c='black')
    right_rotate(1, 130, 5)
    right_rotate(1, 15, 5)
    right_rotate(1, 150, 5)
    goto(30, -88)
    fillcolor('black')
    end_fill()
    fill_color_patch(25, -89)
    begin_fill()
    set_start(25, -89, w=1, c='black')
    right_rotate(1, 140, 8)
    right_rotate(1, 95, 4)
    left_rotate(2, 25, 6)
    right_rotate(1, 130, 8)
    right_rotate(1, 110, 3)
    left_rotate(3, 20, 4)
    goto(25, -89)
    fillcolor('black')
    end_fill()
    fill_color_patch(20, -106)
    begin_fill()
    set_start(20, -106, w=1, c='black')
    right_rotate(1, 180, 8)
    right_rotate(1, 120, 4)
    left_rotate(3, 18, 5.8)
    right_rotate(1, 120, 8)
    right_rotate(1, 110, 3)
    left_rotate(3, 14, 5)
    goto(20, -106)
    fillcolor('black')
    end_fill()
    fill_color_patch(-8, -117)
    begin_fill()
    set_start(-8, -117, w=1, c='black')
    right_rotate(1, 100, 8)
    right_rotate(1, 115, 4)
    left_rotate(2, 16, 5)
    left_rotate(1, 22, 6)
    right_rotate(1, 125, 8)
    right_rotate(1, 120, 3)
    left_rotate(1, 25, 4)
    left_rotate(3, 15, 4)
    goto(-8, -117)
    fillcolor('black')
    end_fill()
    fill_color_patch(-12, -137)
    begin_fill()
    set_start(-12, -137, w=1, c='black')
    right_rotate(1, 145, 8)
    right_rotate(1, 148, 4)
    left_rotate(2, 18, 3.2)
    right_rotate(1, 55, 7)
    right_rotate(1, 165, 3)
    left_rotate(3, 20, 3)
    goto(-12, -137)
    fillcolor('black')
    end_fill()
    fill_color_patch(-6, -144)
    begin_fill()
    set_start(-6, -144, w=1, c='black')
    right_rotate(1, 35, 6)
    right_rotate(1, 105, 4)
    left_rotate(3, 16, 5.5)
    right_rotate(1, 130, 5)
    right_rotate(1, 78, 3)
    left_rotate(3, 5, 4)
    goto(-6, -144)
    fillcolor('black')
    end_fill()
    fill_color_patch(23, -115)
    begin_fill()
    set_start(23, -115, w=1, c='black')
    right_rotate(1, 60, 8)
    right_rotate(1, 120, 4)
    left_rotate(3, 12, 5.3)
    right_rotate(1, 100, 8)
    right_rotate(1, 130, 3)
    left_rotate(3, 15, 5)
    goto(23, -115)
    fillcolor('black')
    end_fill()
    fill_color_patch(32, -133)
    begin_fill()
    set_start(32, -133, w=1, c='black')
    right_rotate(1, 140, 6)
    right_rotate(1, 110, 4)
    left_rotate(3, 8, 5)
    right_rotate(1, 80, 7)
    right_rotate(1, 140, 3)
    left_rotate(3, 14, 6)
    goto(32, -133)
    fillcolor('black')
    end_fill()
    fill_color_patch(39, -135)
    begin_fill()
    set_start(39, -135, w=1, c='black')
    right_rotate(1, 30, 7)
    right_rotate(1, 80, 3)
    left_rotate(3, 20, 2.2)
    right_rotate(1, 160, 5)
    right_rotate(1, 60, 3)
    left_rotate(2, 15, 3)
    goto(39, -135)
    fillcolor('black')
    end_fill()
    fill_color_patch(14, -153)
    begin_fill()
    set_start(14, -153, w=1, c='black')
    right_rotate(1, 90, 7)
    right_rotate(1, 130, 3.5)
    right_rotate(1, 60, 3)
    goto(14, -153)
    fillcolor('black')
    end_fill()
if __name__ == '__main__':
    title('足球')
    wide = 600
    height = 500
    screensize(wide, height)
    setup(wide+30, height+30, 100, 50)
    shape(name='turtle')
    time.sleep(1)
    draw_football()
    set_start(1000, 1000, 1)
    done()
12-06 17:06