前言
2022年是农历壬寅虎年,虎作为十二生肖是家喻户晓的
据学者考证,其应当起源于楚文化中对虎的图腾崇拜,象征力量与威严。
虎者,百兽之王,是威猛的象征,为镇宅辟邪之灵物。
虎在民间习俗中被尊崇为瑞兽。
虎与“福”、“富”谐音,寓意福运临门,富贵盈门。
相传财神赵公明得富贵时有神虎相伴。
据说虎可兴财运,聚赌气纳百财而不损。
而今天给大家用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)
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()
效果展示
尾语 💝
最后,在这里给你虎虎的祝福,虎虎的甜蜜,虎虎的运气,
虎虎的健康,虎虎的快乐,虎虎的心情,虎虎的欣慰,
虎虎的顺利,虎虎的幸福,虎虎的人生。
完整的源码见文末哈自取啦~(往期的也大部分都有源码滴可以找我免费拿撒)