|
| 1 | +import turtle as t |
| 2 | + |
| 3 | + |
| 4 | +def nose(x, y): # 鼻子 |
| 5 | + t.penup() |
| 6 | + t.goto(x, y) |
| 7 | + t.pendown() |
| 8 | + t.setheading(-30) |
| 9 | + t.begin_fill() |
| 10 | + a = 0.4 |
| 11 | + for i in range(120): |
| 12 | + if 0 <= i < 30 or 60 <= i < 90: |
| 13 | + a = a + 0.08 |
| 14 | + t.left(3) |
| 15 | + t.forward(a) |
| 16 | + else: |
| 17 | + a = a - 0.08 |
| 18 | + t.left(3) |
| 19 | + t.forward(a) |
| 20 | + t.end_fill() |
| 21 | + |
| 22 | + t.penup() |
| 23 | + t.setheading(90) |
| 24 | + t.forward(25) |
| 25 | + t.setheading(0) |
| 26 | + t.forward(10) |
| 27 | + t.pendown() |
| 28 | + t.pencolor(255, 155, 192) |
| 29 | + t.setheading(10) |
| 30 | + t.begin_fill() |
| 31 | + t.circle(5) |
| 32 | + t.color(160, 82, 45) |
| 33 | + t.end_fill() |
| 34 | + |
| 35 | + t.penup() |
| 36 | + t.setheading(0) |
| 37 | + t.forward(20) |
| 38 | + t.pendown() |
| 39 | + t.pencolor(255, 155, 192) |
| 40 | + t.setheading(10) |
| 41 | + t.begin_fill() |
| 42 | + t.circle(5) |
| 43 | + t.color(160, 82, 45) |
| 44 | + t.end_fill() |
| 45 | + |
| 46 | + |
| 47 | +def head(x, y): # 头 |
| 48 | + t.color((255, 155, 192), "pink") |
| 49 | + t.penup() |
| 50 | + t.goto(x, y) |
| 51 | + t.setheading(0) |
| 52 | + t.pendown() |
| 53 | + t.begin_fill() |
| 54 | + t.setheading(180) |
| 55 | + t.circle(300, -30) |
| 56 | + t.circle(100, -60) |
| 57 | + t.circle(80, -100) |
| 58 | + t.circle(150, -20) |
| 59 | + t.circle(60, -95) |
| 60 | + t.setheading(161) |
| 61 | + t.circle(-300, 15) |
| 62 | + t.penup() |
| 63 | + t.goto(-100, 100) |
| 64 | + t.pendown() |
| 65 | + t.setheading(-30) |
| 66 | + a = 0.4 |
| 67 | + for i in range(60): |
| 68 | + if 0 <= i < 30 or 60 <= i < 90: |
| 69 | + a = a + 0.08 |
| 70 | + t.lt(3) |
| 71 | + t.fd(a) |
| 72 | + else: |
| 73 | + a = a - 0.08 |
| 74 | + t.lt(3) |
| 75 | + t.fd(a) |
| 76 | + t.end_fill() |
| 77 | + |
| 78 | + |
| 79 | +def ears(x, y): # 耳朵 |
| 80 | + t.color((255, 155, 192), "pink") |
| 81 | + t.penup() |
| 82 | + t.goto(x, y) |
| 83 | + t.pendown() |
| 84 | + t.begin_fill() |
| 85 | + t.setheading(100) |
| 86 | + t.circle(-50, 50) |
| 87 | + t.circle(-10, 120) |
| 88 | + t.circle(-50, 54) |
| 89 | + t.end_fill() |
| 90 | + |
| 91 | + t.penup() |
| 92 | + t.setheading(90) |
| 93 | + t.forward(-12) |
| 94 | + t.setheading(0) |
| 95 | + t.forward(30) |
| 96 | + t.pendown() |
| 97 | + t.begin_fill() |
| 98 | + t.setheading(100) |
| 99 | + t.circle(-50, 50) |
| 100 | + t.circle(-10, 120) |
| 101 | + t.circle(-50, 56) |
| 102 | + t.end_fill() |
| 103 | + |
| 104 | + |
| 105 | +def eyes(x, y): # 眼睛 |
| 106 | + t.color((255, 155, 192), "white") |
| 107 | + t.penup() |
| 108 | + t.setheading(90) |
| 109 | + t.forward(-20) |
| 110 | + t.setheading(0) |
| 111 | + t.forward(-95) |
| 112 | + t.pendown() |
| 113 | + t.begin_fill() |
| 114 | + t.circle(15) |
| 115 | + t.end_fill() |
| 116 | + |
| 117 | + t.color("black") |
| 118 | + t.penup() |
| 119 | + t.setheading(90) |
| 120 | + t.forward(12) |
| 121 | + t.setheading(0) |
| 122 | + t.forward(-3) |
| 123 | + t.pendown() |
| 124 | + t.begin_fill() |
| 125 | + t.circle(3) |
| 126 | + t.end_fill() |
| 127 | + |
| 128 | + t.color((255, 155, 192), "white") |
| 129 | + t.penup() |
| 130 | + t.seth(90) |
| 131 | + t.forward(-25) |
| 132 | + t.seth(0) |
| 133 | + t.forward(40) |
| 134 | + t.pendown() |
| 135 | + t.begin_fill() |
| 136 | + t.circle(15) |
| 137 | + t.end_fill() |
| 138 | + |
| 139 | + t.color("black") |
| 140 | + t.penup() |
| 141 | + t.setheading(90) |
| 142 | + t.forward(12) |
| 143 | + t.setheading(0) |
| 144 | + t.forward(-3) |
| 145 | + t.pendown() |
| 146 | + t.begin_fill() |
| 147 | + t.circle(3) |
| 148 | + t.end_fill() |
| 149 | + |
| 150 | + |
| 151 | +def cheek(x, y): # 腮 |
| 152 | + t.color((255, 155, 192)) |
| 153 | + t.penup() |
| 154 | + t.goto(x, y) |
| 155 | + t.pendown() |
| 156 | + t.setheading(0) |
| 157 | + t.begin_fill() |
| 158 | + t.circle(30) |
| 159 | + t.end_fill() |
| 160 | + |
| 161 | + |
| 162 | +def mouth(x, y): # 嘴 |
| 163 | + t.color(239, 69, 19) |
| 164 | + t.penup() |
| 165 | + t.goto(x, y) |
| 166 | + t.pendown() |
| 167 | + t.setheading(-80) |
| 168 | + t.circle(30, 40) |
| 169 | + t.circle(40, 80) |
| 170 | + |
| 171 | + |
| 172 | +def body(x, y): # 身体 |
| 173 | + t.color("red", (255, 99, 71)) |
| 174 | + t.penup() |
| 175 | + t.goto(x, y) |
| 176 | + t.pendown() |
| 177 | + t.begin_fill() |
| 178 | + t.setheading(-130) |
| 179 | + t.circle(100, 10) |
| 180 | + t.circle(300, 30) |
| 181 | + t.setheading(0) |
| 182 | + t.forward(230) |
| 183 | + t.setheading(90) |
| 184 | + t.circle(300, 30) |
| 185 | + t.circle(100, 3) |
| 186 | + t.color((255, 155, 192), (255, 100, 100)) |
| 187 | + t.setheading(-135) |
| 188 | + t.circle(-80, 63) |
| 189 | + t.circle(-150, 24) |
| 190 | + t.end_fill() |
| 191 | + |
| 192 | + |
| 193 | +def hands(x, y): # 手 |
| 194 | + t.color((255, 155, 192)) |
| 195 | + t.penup() |
| 196 | + t.goto(x, y) |
| 197 | + t.pendown() |
| 198 | + t.setheading(-160) |
| 199 | + t.circle(300, 15) |
| 200 | + t.penup() |
| 201 | + t.setheading(90) |
| 202 | + t.forward(15) |
| 203 | + t.setheading(0) |
| 204 | + t.forward(0) |
| 205 | + t.pendown() |
| 206 | + t.setheading(-10) |
| 207 | + t.circle(-20, 90) |
| 208 | + |
| 209 | + t.penup() |
| 210 | + t.setheading(90) |
| 211 | + t.forward(30) |
| 212 | + t.setheading(0) |
| 213 | + t.forward(237) |
| 214 | + t.pendown() |
| 215 | + t.setheading(-20) |
| 216 | + t.circle(-300, 15) |
| 217 | + t.penup() |
| 218 | + t.setheading(90) |
| 219 | + t.forward(20) |
| 220 | + t.setheading(0) |
| 221 | + t.forward(0) |
| 222 | + t.pendown() |
| 223 | + t.setheading(-170) |
| 224 | + t.circle(20, 90) |
| 225 | + |
| 226 | + |
| 227 | +def foot(x, y): # 脚 |
| 228 | + t.pensize(10) |
| 229 | + t.color((240, 128, 128)) |
| 230 | + t.penup() |
| 231 | + t.goto(x, y) |
| 232 | + t.pendown() |
| 233 | + t.setheading(-90) |
| 234 | + t.forward(40) |
| 235 | + t.setheading(-180) |
| 236 | + t.color("black") |
| 237 | + t.pensize(15) |
| 238 | + t.fd(20) |
| 239 | + |
| 240 | + t.pensize(10) |
| 241 | + t.color((240, 128, 128)) |
| 242 | + t.penup() |
| 243 | + t.setheading(90) |
| 244 | + t.forward(40) |
| 245 | + t.setheading(0) |
| 246 | + t.forward(90) |
| 247 | + t.pendown() |
| 248 | + t.setheading(-90) |
| 249 | + t.forward(40) |
| 250 | + t.setheading(-180) |
| 251 | + t.color("black") |
| 252 | + t.pensize(15) |
| 253 | + t.fd(20) |
| 254 | + |
| 255 | + |
| 256 | +def tail(x, y): # 尾巴 |
| 257 | + t.pensize(4) |
| 258 | + t.color((255, 155, 192)) |
| 259 | + t.penup() |
| 260 | + t.goto(x, y) |
| 261 | + t.pendown() |
| 262 | + t.seth(0) |
| 263 | + t.circle(70, 20) |
| 264 | + t.circle(10, 330) |
| 265 | + t.circle(70, 30) |
| 266 | + |
| 267 | + |
| 268 | +def setting(): # 参数设置 |
| 269 | + t.pensize(4) |
| 270 | + t.hideturtle() |
| 271 | + t.colormode(255) |
| 272 | + t.color((255, 155, 192), "pink") |
| 273 | + t.setup(840, 500) |
| 274 | + t.speed(10) |
| 275 | + |
| 276 | + |
| 277 | +def main(): |
| 278 | + setting() # 设置 |
| 279 | + nose(-100, 100) # 鼻子 |
| 280 | + head(-69, 167) # 头 |
| 281 | + ears(0, 160) # 耳朵 |
| 282 | + eyes(0, 140) # 眼睛 |
| 283 | + cheek(80, 10) # 腮 |
| 284 | + mouth(-20, 30) # 嘴 |
| 285 | + body(-32, -8) # 身体 |
| 286 | + hands(-56, -45) # 手 |
| 287 | + foot(2, -177) # 脚 |
| 288 | + tail(148, -155) # 尾巴 |
| 289 | + t.done() |
| 290 | + |
| 291 | + |
| 292 | +if __name__ == '__main__': |
| 293 | + main() |
0 commit comments