【python Turtle源码】教你如何画一只迎福虎将~

前言

大家早好、午好、晚好吖 ❤ ~

代码展示

导入模块

from turtle import *
import time

因代码体量有点多

这里就给大家部分展示了,有需要的可以文章下方名片获取哦~

(或者评论已点赞收藏,求代码,我私你呀)

COLOR = '#B2814D'


def set_start(x, y, w, c=COLOR):
    penup()
    setx(x)
    sety(y)
    setheading(towards(0, 0))
    width(w)
    pencolor(c)
    pendown()
    speed(0)


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_circle(radius, color, color2=''):
    if color2 == '':
        color2 = color
    penup()
    setheading(towards(0, 0))
    right(90)
    pencolor(color)
    pendown()
    begin_fill()
    circle(radius)
    fillcolor(color2)
    end_fill()


def fill_color(color):
    def decorator_all(func):
        def wrapper(*args, **kwargs):
            begin_fill()
            func(*args, **kwargs)
            fillcolor(color)
            end_fill()
        return wrapper
    return decorator_all


def fill_color_patch(x, y, c='#fffffb'):
    set_start(x, y, 1, c=c)
    forward(1)


def head_outline():
    set_start(0, -40, 2.5)
    right(90)
    left_rotate(5, 3, 14)
    left_rotate(5, 8, 8)
    left_rotate(10, 5, 6.5)
    left_rotate(5, 5.5, 10)
    left_rotate(25, 4, 10)
    left_rotate(6, 5.5, 5)
    left_rotate(7, 3, 7)
    left_rotate(5, 10, 8)
    left_rotate(5, 3, 14)


@fill_color('#fdb933')
def draw_head():
    head_outline()
    pencolor('#CDCDCD')
    goto(0, -40)
@fill_color('#fffffb')
def draw_face():
    set_start(0, -40, 2.5)
    right(90)
    left_rotate(5, 3, 14)
    left_rotate(1, 80, 2.5)
    pencolor('#fffffb')
    left_rotate(12, 5, 6.5)
    left_rotate(5, 6, 15)
    left_rotate(5, 5, 10)
    left_rotate(5, 12, 10)
    backward(0.5)
    left(65)
    pencolor(COLOR)
    backward(3)
    left_rotate(5, 3, 14)
    forward(5)


def draw_moustache():
    fill_color_patch(-41, -31)
    begin_fill()
    set_start(-41, -31, 2.5)
    right(180)
    left_rotate(4, 20, 4)
    left_rotate(1, 90, 8)
    right(150)
    left_rotate(4, 25, 3)
    forward(6)
    left_rotate(1, 110, 5.5)
    right(165)
    left_rotate(4, 15, 3.2)
    left(150)
    right_rotate(3, 30, 2.2)
    right_rotate(1, 105, 5)
    left(130)
    right_rotate(6, 5, 1.8)
    right_rotate(1, 130, 2)
    left(60)
    left_rotate(2, 30, 1)
    left_rotate(4, 28, 4
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值