本来想画兰那罗的,但是太复杂了。还是锅巴好画。

调参真的痛苦。

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# guoba.py
import math
import turtle as tu

def guoba_ellipse(a, b, n=500, x=0, y=0, alpha=360, sangle=0, workangle=360, myflag=False):
"""
绘制椭圆
a:长半轴长度
b:短半轴长度
n:越大越趋近椭圆
x:几何中心x坐标
y:几何中心y坐标
alpha:椭圆旋转的角度
sangle:开始绘制点与椭圆长半轴正方向的夹角(角度)
workangle:绘制一部分椭圆(角度),默认为整个椭圆
myflag:判断是否仅需要调整画笔位置
"""
alpha = (2*math.pi/360)*alpha # 角度制换算弧度值
sangle = (2*math.pi/360)*sangle
workangle = (2*math.pi/360)*workangle
theta = sangle
# 参数方程,旋转的部分按旋转矩阵推导:
start_point = (a*math.cos(theta)*math.cos(alpha) - b*math.sin(theta)*math.sin(alpha) + x,
a*math.cos(theta)*math.sin(alpha) + b*math.sin(theta)*math.cos(alpha) + y)
tu.penup()
tu.setpos(start_point) # 初始位置
if myflag:
return
tu.pendown()
microtheta = 2 * math.pi / n # 将2pi弧度n等分
for i in range(n):
theta = sangle + (i+1)*microtheta # 弧度增加
if (theta-sangle) > workangle:
break
next_point = (a*math.cos(theta)*math.cos(alpha) - b*math.sin(theta)*math.sin(alpha) + x,
a*math.cos(theta)*math.sin(alpha) + b*math.sin(theta)*math.cos(alpha) + y)
tu.setpos(next_point)
tu.penup()

tu.setup(700,700)
tu.speed(10)
tu.delay(0)
tu.pensize(25)
tu.colormode(255)

tu.pencolor((255,193,37))
tu.fillcolor((255,193,37))
tu.begin_fill()
guoba_ellipse(250, 210, 500, 0, -70, 360, -45, 270) # 脸
tu.pendown()
tu.setpos(179, -220)
tu.end_fill()

tu.begin_fill()
guoba_ellipse(75, 70, 500, 160, 150, -30) # 右耳朵
tu.end_fill()
tu.begin_fill()
guoba_ellipse(80, 77, 500, -160, 150, 45) # 左耳朵
tu.end_fill()

tu.fillcolor((205, 155, 29)) # 画笔颜色忘换了。参数调好就别动,效果一样
tu.begin_fill()
guoba_ellipse(50, 45, 500, 165, 140, -33) # 右耳朵内部
tu.end_fill()
tu.begin_fill()
guoba_ellipse(53, 47, 500, -155, 140, 30) # 左耳朵内部
tu.end_fill()

tu.pensize(15)
tu.pencolor((238, 121, 66))
tu.fillcolor((238, 121, 66))
tu.begin_fill()
guoba_ellipse(45, 48, 500, -165, -45, 0) # 左腮红
tu.end_fill()
tu.begin_fill()
guoba_ellipse(30, 50, 500, 170, -45, 15) # 右腮红
tu.end_fill()

tu.pensize(5)
tu.pencolor((0, 0, 0))
# ------------------------ 眼 罩 ------------------------#
guoba_ellipse(280, 185, 500, -5, 107, 2, -121, 62, True) #
tu.fillcolor((0, 0, 0)) #
tu.begin_fill() #
guoba_ellipse(280, 185, 500, -5, 107, 2, -121, 62) #
tu.seth(25) #
tu.pendown() #
tu.circle(55, 210) #
tu.penup() #
tu.setpos(-145, -55) #
tu.pendown() #
tu.seth(157) #
tu.circle(-55, 210) #
guoba_ellipse(120, 80, 500, -5, 95, -1, -135, 90) #
tu.end_fill() #
tu.pendown() #
tu.setpos(-145, -55) #
# ------------------------ 眼 罩 ------------------------#

tu.begin_fill()
guoba_ellipse(22, 15, 300, -105, 105, 25) # 左眉毛
tu.end_fill()
tu.begin_fill()
guoba_ellipse(18, 10, 300, 130, 100, -36) # 右眉毛
tu.end_fill()

tu.pencolor((255, 255, 224))
tu.fillcolor((255, 255, 224))
tu.begin_fill()
guoba_ellipse(80, 45, 500, -5, 65) # 额头白色部分
tu.end_fill()
tu.pencolor((255,193,37))
tu.fillcolor((255,193,37))
tu.begin_fill()
guoba_ellipse(50, 31, 400, -5, 50) # 额头黄色部分
tu.end_fill()

tu.pencolor((255, 250, 250))
tu.fillcolor((255, 250, 250))
guoba_ellipse(21, 35, 400, -115, -8, 7, 0, 360, True)
tu.begin_fill()
guoba_ellipse(21, 35, 400, -115, -8, 7) # 左眼白
tu.end_fill()
tu.begin_fill()
guoba_ellipse(20, 33.5, 500, 120, 0, 4) # 右眼白
tu.end_fill()

# ----------------------- 胡 子 --------------------------#
tu.pencolor((255, 255, 255)) #
tu.fillcolor((255, 255, 255)) #
tu.begin_fill() #
guoba_ellipse(85, 20, 500, 5, -60, 0) #
tu.end_fill() #
guoba_ellipse(85, 20, 500, 5, -60, 0, 140, 360, True) #
tu.seth(-170) #
tu.begin_fill() #
tu.circle(60) #
tu.end_fill() #
guoba_ellipse(85, 20, 500, 5, -60, 0, 40, 360, True) #
tu.seth(-10) #
tu.begin_fill() #
tu.circle(-60) #
tu.end_fill() #
tu.penup() #
# ----------------------- 胡 子 --------------------------#

tu.pencolor((255, 160, 122))
tu.fillcolor((255, 160, 122))
tu.begin_fill()
guoba_ellipse(80, 50, 500, 4, -37, -8, -120, 35) #鼻子
guoba_ellipse(80, 50, 500, 13, -31, 30, -115, 30)
tu.pendown()
tu.setpos(-39.5, -73)
tu.end_fill()

tu.pencolor((0, 0, 0))
tu.pensize(2)
guoba_ellipse(4.2, 7, 400, -115, -8, 7) # 左眼珠
guoba_ellipse(4, 6.7, 500, 120, 0, 4) # 右眼珠
tu.penup()
tu.setpos(690,690)
tu.done()