前言
大家早好、午好、晚好吖 ❤ ~
代码展示
导入模块
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)
fillcolor('#fffffb')
end_fill()
set_start(-45, -28, 2.5)
right(70)
left_rotate(5, 2.5, 4)
left_rotate(4, 9, 3)
left_rotate(5, 3, 4.5)
def draw_mouth():
set_start(-17, 22, 2.5)
right_rotate(1, 45, 14)
left_rotate(1, 85, 35)
left_rotate(1, 70, 7)
set_start(-17, 22, 2.5)
right_rotate(1, 45, 14)
right_rotate(1, 78, 36)
right_rotate(1, 65, 6)
set_start(-17, 22, 2.5)
right_rotate(1, 45, 14)
left_rotate(1, 85, 30)
right_rotate(1, 108, 12)
right_rotate(1, 140, 5)
set_start(-17, 22, 2.5)
right_rotate(1, 45, 14)
right_rotate(1, 75, 28)
left_rotate(1, 85, 10)
left_rotate(1, 130, 8)
set_start(3, 0, 2.5)
left(90)
right_rotate(5, 5, 4.8)
right_rotate(4, 18, 1.8)
left_rotate(1, 3, 27)
right_rotate(4, 18, 1)
right_rotate(1, 15, 22)
right(88)
right_rotate(9, 1, 4.5)
begin_fill()
set_start(3, 0, 2.5)
left(90)
right_rotate(4, 5, 4.8)
right_rotate(1, 5, 2)
right_rotate(1, 67, 37)
right_rotate(1, 86, 18)
fillcolor('#f15a22')
end_fill()
begin_fill()
set_start(3, 0, 2.5)
pencolor('#aa2116')
left(90)
right_rotate(2, 5, 6)
right(120)
left_rotate(10, 6, 2)
right(55)
left_rotate(11, 5.5, 1.8)
right_rotate(1, 110, 10)
right(100)
right_rotate(9, 1, 4.5)
fillcolor('#aa2116')
end_fill()
set_start(3, 0, 2.5)
left(90)
right_rotate(5, 5, 4.8)
right_rotate(4, 18, 1.8)
left_rotate(1, 3, 27)
right_rotate(4, 18, 1)
right_rotate(1, 15, 22)
right(88)
right_rotate(9, 1, 4.5)
set_start(21, 10, 1, c='#fdb933')
draw_circle(2.3, '#fdb933')
set_start(10, 16, 1, c='#fdb933')
draw_circle(2.3, '#fdb933')
set_start(21, 19, 1, c='#fdb933')
draw_circle(2.3, '#fdb933')
set_start(-57, 16, 1, c='#fdb933')
draw_circle(2.3, '#fdb933')
set_start(-51, 24, 1, c='#fdb933')
draw_circle(2.3, '#fdb933')
set_start(-64, 24, 1, c='#fdb933')
draw_circle(2.3, '#fdb933')
def draw_nose():
set_start(6, 37, 1)
pencolor('#e0861a')
right(150)
begin_fill()
left_rotate(6, 3, 4)
left_rotate(6, 15, 3)
left_rotate(6, 3, 4)
fillcolor('#e0861a')
end_fill()
set_start(6, 37, 1.5)
right(120)
begin_fill()
left_rotate(5, 4, 4)
left_rotate(3, 10, 3)
left_rotate(5, 4, 4)
left_rotate(7, 15, 0.8)
left_rotate(5, 4, 4)
left_rotate(5, 8, 2)
left_rotate(5, 4, 4)
left_rotate(7, 15, 0.8)
fillcolor('#b4532a')
end_fill()
set_start(-16, 36, 1)
pencolor('#d1923f')
right(75)
begin_fill()
right_rotate(4, 15, 2)
right_rotate(5, 26, 1)
right_rotate(4, 15, 2)
right_rotate(5, 26, 1)
fillcolor('#d1923f')
end_fill()
set_start(-25, 25, 1)
pencolor('#130c0e')
left(110)
begin_fill()
left_rotate(6, 15, 1.5)
left_rotate(5, 15, 1)
fillcolor('#130c0e')
end_fill()
set_start(-10, 24, 1)
pencolor('#130c0e')
left(175)
begin_fill()
right_rotate(6, 15, 1.2)
right_rotate(5, 15, 1)
fillcolor('#130c0e')
end_fill()
def draw_eye():
set_start(-50, 34, 1, c='#130c0e')
left(115)
begin_fill()
left_rotate(8, 6.5, 7)
left_rotate(5, 15, 7)
left_rotate(5, 10, 5.5)
left_rotate(5, 15, 6)
left_rotate(5, 5, 9.5)
left_rotate(4, 30, 2)
fillcolor('#130c0e')
end_fill()
set_start(-57, 40, 1, c='#fffffb')
left(112)
begin_fill()
left_rotate(8, 6.5, 5)
left_rotate(5, 15, 6)
left_rotate(5, 10, 4.5)
left_rotate(5, 15, 5)
left_rotate(5, 6.5, 7)
left_rotate(4, 15, 2)
fillcolor('#fffffb')
end_fill()
set_start(-90, 62, 1, c='#563624')
draw_circle(15, '#563624')
set_start(-84, 59, 1, c='#130c0e')
draw_circle(9, '#130c0e')
set_start(-90, 63, 1, c='#fffffb')
draw_circle(3.5, '#fffffb')
set_start(16, 25, 1, c='#130c0e')
right(150)
begin_fill()
right_rotate(8, 6.5, 7)
right_rotate(5, 15, 7)
right_rotate(5, 10, 5.5)
right_rotate(5, 15, 6)
right_rotate(5, 5, 9.5)
right_rotate(4, 30, 2)
fillcolor('#130c0e')
end_fill()
set_start(24, 28, 1, c='#fffffb')
right(135)
begin_fill()
right_rotate(8, 7, 5)
right_rotate(5, 15, 5.5)
right_rotate(5, 10, 4.5)
right_rotate(5, 15, 4.5)
right_rotate(5, 6.5, 6.5)
right_rotate(4, 13, 2)
fillcolor('#fffffb')
end_fill()
set_start(57, 48, 1, c='#563624')
draw_circle(15, '#563624')
set_start(53, 44, 1, c='#130c0e')
draw_circle(9, '#130c0e')
set_start(38, 47, 1, c='#fffffb')
draw_circle(3.5, '#fffffb')
def draw_brow():
set_start(12, 88, 1, c='#130c0e')
right(82)
begin_fill()
left_rotate(3, 3, 5)
right_rotate(5, 4, 6)
right_rotate(7, 24, 2.3)
right_rotate(3, 5, 4.5)
left_rotate(1, 90, 8)
left(95)
left_rotate(3, 8, 5)
right_rotate(3, 25, 1.2)
right_rotate(3, 11, 1.5)
right_rotate(3, 25, 1.2)
right_rotate(3, 3, 4.5)
left_rotate(1, 85, 7)
left_rotate(1, 90, 15)
right_rotate(5, 30, 2.2)
right_rotate(3, 9, 6)
right_rotate(6, 3, 5)
right_rotate(8, 18, 1.3)
right_rotate(3, 10, 5.3)
left_rotate(1, 90, 8)
left(112)
right_rotate(3, 3, 4.5)
right_rotate(3, 25, 1)
right_rotate(3, 10, 1.5)
right_rotate(3, 28, 1)
left_rotate(3, 5, 3)
left_rotate(3, 25, 1)
left_rotate(3, 5, 1.8)
left_rotate(1, 90, 17)
right_rotate(3, 35, 0.8)
right_rotate(3, 10, 3)
fillcolor('#130c0e')
end_fill()
set_start(88, -16, 1, c='#130c0e')
begin_fill()
right_rotate(5, 15, 3)
right_rotate(4, 5.5, 3)
right_rotate(3, 28, 1)
right_rotate(5, 6, 4)
fillcolor('#130c0e')
end_fill()
set_start(106, 9, 1, c='#130c0e')
right(15)
begin_fill()
right_rotate(5, 5, 5.5)
right_rotate(5, 29, 3)
right_rotate(5, 5, 4.5)
fillcolor('#130c0e')
end_fill()
set_start(110, 36, 1, c='#130c0e')
left(20)
begin_fill()
right_rotate(3, 10, 2)
right_rotate(3, 10, 6)
right_rotate(5, 29, 2)
forward(20)
fillcolor('#130c0e')
end_fill()
set_start(75, 76, 1, c='#130c0e')
right(105)
begin_fill()
left_rotate(5, 10, 4)
right_rotate(6, 28, 2)
right_rotate(5, 10, 5)
right_rotate(6, 25, 2)
fillcolor('#130c0e')
end_fill()
set_start(-75, 100, 1, c='#130c0e')
right(108)
begin_fill()
right_rotate(3, 3, 8)
right_rotate(4, 35, 2)
right_rotate(8, 9, 3.2)
fillcolor('#130c0e')
end_fill()
set_start(-145, 58, 1, c='#130c0e')
right(30)
begin_fill()
left_rotate(5, 15, 5)
left_rotate(3, 18, 3)
left(92)
right_rotate(4, 5, 6)
right_rotate(1, 5, 4)
fillcolor('#130c0e')
end_fill()
set_start(-148, 46, 1, c='#130c0e')
left(40)
begin_fill()
right_rotate(5, 10, 6.5)
right_rotate(4, 32, 2)
right_rotate(4, 10, 6.5)
fillcolor('#130c0e')
end_fill()
set_start(-138, 7, 1, c='#130c0e')
left(10)
begin_fill()
left_rotate(5, 8, 4)
left_rotate(6, 20, 1.5)
left_rotate(4, 8, 4.5)
fillcolor('#130c0e')
end_fill()
head_outline()
def draw_ear():
set_start(101, 74, 2.5)
left(150)
begin_fill()
left_rotate(5, 6, 3)
left_rotate(5, 12, 5)
left_rotate(3, 13, 12)
left_rotate(5, 12, 7)
left_rotate(4, 16, 5)
fillcolor('#fdb933')
end_fill()
set_start(94, 89, 1, c='#f3715c')
right(168)
begin_fill()
left_rotate(5, 17, 6)
left_rotate(4, 20, 5)
goto(94, 89)
fillcolor('#f3715c')
end_fill()
set_start(-125, 98, 2.5)
right(165)
begin_fill()
right_rotate(5, 6, 3)
right_rotate(5, 12, 5)
right_rotate(3, 13, 12)
right_rotate(5, 12, 7)
right_rotate(4, 16, 4.5)
fillcolor('#fdb933')
end_fill()
set_start(-115, 110, 1, c='#f3715c')
left(160)
begin_fill()
right_rotate(5, 17, 6)
right_rotate(4, 20, 5.5)
goto(-115, 110)
fillcolor('#f3715c')
end_fill()
head_outline()
def draw_cap():
set_start(55, 123, 2.5)
right(150)
left_rotate(13, 11, 12)
set_start(18, 170, 2.5)
right(180)
begin_fill()
left_rotate(10, 16, 4)
fillcolor('#130c0e')
end_fill()
set_start(55, 123, 2.5)
right(150)
begin_fill()
left_rotate(13, 11, 12)
fillcolor('#FF0000')
end_fill()
set_start(55, 123, 2.5)
right(113)
begin_fill()
left_rotate(15, 5, 8.6)
fillcolor('#228B22')
end_fill()
set_start(30, 142, 2.5)
right(170)
left_rotate(18, 8.9, 5)
set_start(-2, 150, 2.5)
left(178)
right_rotate(4, 5, 6)
set_start(55, 123, 2.5)
begin_fill()
goto(50.13, 124.56)
setheading(148.5)
left_rotate(12, 4, 10)
fillcolor('#fdb933')
end_fill()
def draw_shadow():
fill_color_patch(75, -155)
_draw_shadow()
效果展示
虎年来历
虎在十二生肖中位居第三,在十二地支配属“寅”,故一天十二时辰中之“寅时”凌晨三点至五点又称“虎时”。
在远古时候,属相中有狮子,没有老虎。
由于狮子太凶残,名声不好,主管封属相的玉皇大帝想把狮子除名,但是又必须补进一位镇管山林的动物。这时,玉帝想到殿前的虎卫士。
天宫的虎卫士从前也只是地上的一种不出名的动物。
它从猫师傅那里学得抓、扑、咬、剪、冲、跃、折等十八般武艺后,成为山林中的勇士。
凡是和它较量的,不死即伤。从此,老虎雄霸山林。
后来,玉帝听说老虎勇猛无比,便下旨传老虎上天。老虎上天之后,同玉帝的卫士较量,赢得胜利。从此,老虎便成了天宫的殿前卫士。
谁知不久之后,地上的飞禽走兽见无人镇管,开始胡作非为起来。
给人间造成了灾难,这事惊动了土地神,土地神连忙上报天庭,请玉帝派统天神镇住百兽。玉帝便派老虎下凡,老虎要求每胜一次,便给它记一功。
玉帝只求人间安宁,当然满口答应老虎的要求。
来了凡间,老虎了解到狮子、熊、马是当时最厉害的三种动物。它就专门向这三种动物挑战。
凭着老虎的勇猛和高超的武艺连接击败了狮子、熊、马。
其他恶兽闻风而逃,藏进了无人居住的森林荒野。人间欢声动地,感谢老虎为人世间立了功。
回到天上,玉帝因老虎连胜三兽,便在它的前额刻下了三条横线。
后来,人间又受到东海龟怪的骚扰,大地一片汪洋。
虾兵蟹将作恶人间,老虎又来到凡间,咬死了龟怪。
玉帝一高兴,又给老虎记一大功,在额头的三横之中又添了一竖。一个醒目的“王”字在老虎前额。
从此,老虎便为百兽之王,总管百兽。时至今天,虎额上也还可见到威风的“王”字。
尾语 💝
最后,祝大家你虎我虎大家虎,老虎迎新解千愁。
喜虎福虎孺子虎,虎言虎语庆丰收。
人生得意虎得草,虎年一笑泯恩仇。
虎铃摇出好春光,一年更比一年虎。
完整的源码见文末哈自取啦~(往期的也大部分都有源码滴可以找我免费拿撒)