├── README.md ├── LICENSE └── Python版 ├── ChristmasTree03.py ├── ChristmasTree01.py ├── ChristmasTree02.py ├── ChristmasTree05_Pink.py └── ChristmasTree04_Green.py /README.md: -------------------------------------------------------------------------------- 1 | > **本文分为两大部分:网页版圣诞树、Python版圣诞树** 2 | > 3 | > 代码来自CSDN作者分享,本人只作为转载写成合集,如有侵权请联系本人删除 4 | 5 | 6 | # 圣诞树合集 7 | 8 | ## 网页版圣诞树 9 | 10 | ### 纯CSS动画圣诞树Demo01 11 | ### 纯CSS螺旋圣诞树Demo02 12 | ### 纯CSS流星圣诞树Demo03 13 | ### 纯CSS水晶球圣诞树Demo04 14 | ### HTML+CSS+JS圣诞树Demo05 15 | ### 圣诞树贺卡Demo06 16 | 17 | ## Python版圣诞树 18 | 19 | ### 马赛克圣诞树 20 | ### 马赛克进阶圣诞树 21 | ### 进阶雪花圣诞树 22 | ### 豪华圣诞树 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 wayjun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Python版/ChristmasTree03.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Descripttion: 3 | version: 4 | Author: WayJun 5 | Date: 2021-12-21 11:09:44 6 | LastEditors: WayJun 7 | LastEditTime: 2021-12-21 11:10:56 8 | ''' 9 | import turtle 10 | # 定义圣诞树的绿叶函数 11 | def tree(d, s): 12 | if d <= 0: 13 | return 14 | turtle.forward(s) 15 | tree(d - 1, s * .8) 16 | turtle.right(120) 17 | tree(d - 3, s * .5) 18 | turtle.right(120) 19 | tree(d - 3, s * .5) 20 | turtle.right(120) 21 | turtle.backward(s) 22 | n = 100 23 | """ 设置绘图速度 24 | 'fastest' : 0 25 | 'fast' : 10 26 | 'normal' : 6 27 | 'slow' : 3 28 | 'slowest' : 1 29 | """ 30 | turtle.speed('fastest') # 设置速度 31 | turtle.left(90) 32 | turtle.forward(3 * n) 33 | turtle.color("orange", "yellow") 34 | turtle.left(126) 35 | # turtle.begin_fill() 36 | for i in range(5): 37 | turtle.forward(n / 5) 38 | turtle.right(144) 39 | turtle.forward(n / 5) 40 | turtle.left(72) 41 | turtle.end_fill() 42 | turtle.right(126) 43 | turtle.color("dark green") 44 | turtle.backward(n * 4.8) 45 | # 执行函数 46 | tree(15, n) 47 | turtle.backward(n / 5) 48 | turtle.done() -------------------------------------------------------------------------------- /Python版/ChristmasTree01.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Descripttion: 3 | version: 4 | Author: WayJun 5 | Date: 2021-12-21 11:11:34 6 | LastEditors: WayJun 7 | LastEditTime: 2021-12-21 11:13:15 8 | ''' 9 | import turtle 10 | screen = turtle.Screen() 11 | screen.setup(800,600) 12 | circle = turtle.Turtle() 13 | circle.shape('circle') 14 | circle.color('red') 15 | circle.speed('fastest') 16 | circle.up() 17 | square = turtle.Turtle() 18 | square.shape('square') 19 | square.color('green') 20 | square.speed('fastest') 21 | square.up() 22 | circle.goto(0,280) 23 | circle.stamp() 24 | k = 0 25 | for i in range(1, 17): 26 | y = 30*i 27 | for j in range(i-k): 28 | x = 30*j 29 | square.goto(x,-y+280) 30 | square.stamp() 31 | square.goto(-x,-y+280) 32 | square.stamp() 33 | if i % 4 == 0: 34 | x = 30*(j+1) 35 | circle.color('red') 36 | circle.goto(-x,-y+280) 37 | circle.stamp() 38 | circle.goto(x,-y+280) 39 | circle.stamp() 40 | k += 2 41 | if i % 4 == 3: 42 | x = 30*(j+1) 43 | circle.color('yellow') 44 | circle.goto(-x,-y+280) 45 | circle.stamp() 46 | circle.goto(x,-y+280) 47 | circle.stamp() 48 | square.color('brown') 49 | for i in range(17,20): 50 | y = 30*i 51 | for j in range(3): 52 | x = 30*j 53 | square.goto(x,-y+280) 54 | square.stamp() 55 | square.goto(-x,-y+280) 56 | square.stamp() 57 | turtle.exitonclick() 58 | -------------------------------------------------------------------------------- /Python版/ChristmasTree02.py: -------------------------------------------------------------------------------- 1 | import turtle as t # as就是取个别名,后续调用的t都是turtle 2 | from turtle import * 3 | import random as r 4 | import time 5 | 6 | n = 100.0 7 | 8 | speed("fastest") # 定义速度 9 | screensize(bg='black') # 定义背景颜色,可以自己换颜色 10 | left(90) 11 | forward(3 * n) 12 | color("orange", "yellow") # 定义最上端星星的颜色,外圈是orange,内部是yellow 13 | begin_fill() 14 | left(126) 15 | 16 | for i in range(5): # 画五角星 17 | forward(n / 5) 18 | right(144) # 五角星的角度 19 | forward(n / 5) 20 | left(72) # 继续换角度 21 | end_fill() 22 | right(126) 23 | 24 | 25 | def drawlight(): # 定义画彩灯的方法 26 | if r.randint(0, 30) == 0: # 如果觉得彩灯太多,可以把取值范围加大一些,对应的灯就会少一些 27 | color('tomato') # 定义第一种颜色 28 | circle(6) # 定义彩灯大小 29 | elif r.randint(0, 30) == 1: 30 | color('orange') # 定义第二种颜色 31 | circle(3) # 定义彩灯大小 32 | else: 33 | color('dark green') # 其余的随机数情况下画空的树枝 34 | 35 | 36 | color("dark green") # 定义树枝的颜色 37 | backward(n * 4.8) 38 | 39 | 40 | def tree(d, s): # 开始画树 41 | if d <= 0: return 42 | forward(s) 43 | tree(d - 1, s * .8) 44 | right(120) 45 | tree(d - 3, s * .5) 46 | drawlight() # 同时调用小彩灯的方法 47 | right(120) 48 | tree(d - 3, s * .5) 49 | right(120) 50 | backward(s) 51 | 52 | 53 | tree(15, n) 54 | backward(n / 2) 55 | 56 | for i in range(200): # 循环画最底端的小装饰 57 | a = 200 - 400 * r.random() 58 | b = 10 - 20 * r.random() 59 | up() 60 | forward(b) 61 | left(90) 62 | forward(a) 63 | down() 64 | if r.randint(0, 1) == 0: 65 | color('tomato') 66 | else: 67 | color('wheat') 68 | circle(2) 69 | up() 70 | backward(a) 71 | right(90) 72 | backward(b) 73 | 74 | t.color("dark red", "red") # 定义字体颜色 75 | t.write("Merry Christmas ", align="center", font=("Comic Sans MS", 40, "bold")) # 定义文字、位置、字体、大小 76 | 77 | 78 | def drawsnow(): # 定义画雪花的方法 79 | t.ht() # 隐藏笔头,ht=hideturtle 80 | t.pensize(2) # 定义笔头大小 81 | for i in range(200): # 画多少雪花 82 | t.pencolor("white") # 定义画笔颜色为白色,其实就是雪花为白色 83 | t.pu() # 提笔,pu=penup 84 | t.setx(r.randint(-350, 350)) # 定义x坐标,随机从-350到350之间选择 85 | t.sety(r.randint(-100, 350)) # 定义y坐标,注意雪花一般在地上不会落下,所以不会从太小的纵座轴开始 86 | t.pd() # 落笔,pd=pendown 87 | dens = 6 # 雪花瓣数设为6 88 | snowsize = r.randint(1, 10) # 定义雪花大小 89 | for j in range(dens): # 就是6,那就是画5次,也就是一个雪花五角星 90 | # t.forward(int(snowsize)) #int()取整数 91 | t.fd(int(snowsize)) 92 | t.backward(int(snowsize)) 93 | # t.bd(int(snowsize)) #注意没有bd=backward,但有fd=forward,小bug 94 | t.right(int(360 / dens)) # 转动角度 95 | 96 | 97 | drawsnow() # 调用画雪花的方法 98 | t.done() # 完成,否则会直接关闭 99 | 100 | 101 | -------------------------------------------------------------------------------- /Python版/ChristmasTree05_Pink.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | import time 3 | 4 | setup(500, 500, startx=None, starty=None) 5 | speed(0) 6 | pencolor("pink") 7 | pensize(10) 8 | penup() 9 | hideturtle() 10 | goto(0, 150) 11 | showturtle() 12 | pendown() 13 | shape(name="classic") 14 | # 1 15 | seth(-120) 16 | for i in range(10): 17 | fd(12) 18 | right(2) 19 | penup() 20 | goto(0, 150) 21 | seth(-60) 22 | pendown() 23 | for i in range(10): 24 | fd(12) 25 | left(2) 26 | seth(-150) 27 | penup() 28 | fd(10) 29 | pendown() 30 | for i in range(5): 31 | fd(10) 32 | right(15) 33 | seth(-150) 34 | penup() 35 | fd(8) 36 | pendown() 37 | for i in range(5): 38 | fd(10) 39 | right(15) 40 | seth(-155) 41 | penup() 42 | fd(5) 43 | pendown() 44 | for i in range(5): 45 | fd(7) 46 | right(15) 47 | # 2 48 | penup() 49 | goto(-55, 34) 50 | pendown() 51 | seth(-120) 52 | for i in range(10): 53 | fd(8) 54 | right(5) 55 | 56 | penup() 57 | goto(50, 35) 58 | seth(-60) 59 | pendown() 60 | for i in range(10): 61 | fd(8) 62 | left(5) 63 | seth(-120) 64 | penup() 65 | fd(10) 66 | seth(-145) 67 | pendown() 68 | for i in range(5): 69 | fd(10) 70 | right(15) 71 | penup() 72 | fd(10) 73 | seth(-145) 74 | pendown() 75 | for i in range(5): 76 | fd(12) 77 | right(15) 78 | penup() 79 | fd(8) 80 | seth(-145) 81 | pendown() 82 | for i in range(5): 83 | fd(10) 84 | right(15) 85 | penup() 86 | seth(-155) 87 | fd(8) 88 | pendown() 89 | for i in range(5): 90 | fd(11) 91 | right(15) 92 | # 3 93 | penup() 94 | goto(-100, -40) 95 | seth(-120) 96 | pendown() 97 | for i in range(10): 98 | fd(6) 99 | right(3) 100 | penup() 101 | goto(80, -39) 102 | seth(-50) 103 | pendown() 104 | for i in range(10): 105 | fd(6) 106 | left(3) 107 | seth(-155) 108 | penup() 109 | fd(10) 110 | pendown() 111 | for i in range(5): 112 | fd(8) 113 | right(10) 114 | penup() 115 | fd(8) 116 | seth(-145) 117 | pendown() 118 | for i in range(7): 119 | fd(8) 120 | right(10) 121 | penup() 122 | fd(8) 123 | seth(-145) 124 | pendown() 125 | for i in range(7): 126 | fd(7) 127 | right(10) 128 | penup() 129 | fd(8) 130 | seth(-145) 131 | pendown() 132 | for i in range(7): 133 | fd(7) 134 | right(10) 135 | penup() 136 | fd(8) 137 | seth(-140) 138 | pendown() 139 | for i in range(7): 140 | fd(6) 141 | right(10) 142 | 143 | # 4 144 | penup() 145 | goto(-120, -95) 146 | seth(-130) 147 | pendown() 148 | for i in range(7): 149 | fd(10) 150 | right(5) 151 | penup() 152 | goto(100, -95) 153 | seth(-50) 154 | pendown() 155 | for i in range(7): 156 | fd(10) 157 | left(5) 158 | penup() 159 | seth(-120) 160 | fd(10) 161 | seth(-155) 162 | pendown() 163 | for i in range(6): 164 | fd(8) 165 | right(10) 166 | penup() 167 | seth(-160) 168 | fd(10) 169 | seth(-155) 170 | pendown() 171 | for i in range(6): 172 | fd(8) 173 | right(10) 174 | penup() 175 | seth(-160) 176 | fd(10) 177 | seth(-155) 178 | pendown() 179 | for i in range(6): 180 | fd(8) 181 | right(10) 182 | penup() 183 | seth(-160) 184 | fd(10) 185 | seth(-160) 186 | pendown() 187 | for i in range(6): 188 | fd(8) 189 | right(10) 190 | penup() 191 | seth(-160) 192 | fd(10) 193 | seth(-160) 194 | pendown() 195 | for i in range(6): 196 | fd(8) 197 | right(10) 198 | penup() 199 | seth(-160) 200 | fd(10) 201 | seth(-165) 202 | pendown() 203 | for i in range(5): 204 | fd(10) 205 | right(11) 206 | # 5 207 | penup() 208 | goto(-70, -165) 209 | seth(-85) 210 | pendown() 211 | for i in range(3): 212 | fd(5) 213 | left(3) 214 | penup() 215 | goto(70, -165) 216 | seth(-95) 217 | pendown() 218 | for i in range(3): 219 | fd(5) 220 | right(3) 221 | seth(-170) 222 | penup() 223 | fd(10) 224 | pendown() 225 | pendown() 226 | for i in range(10): 227 | fd(12) 228 | right(2) 229 | # 6 230 | penup() 231 | goto(70, -165) 232 | pendown() 233 | seth(-90) 234 | pensize(8) 235 | pencolor("#de8891") 236 | circle(-20, 90) 237 | 238 | penup() 239 | goto(30, -185) 240 | pendown() 241 | seth(-180) 242 | pensize(8) 243 | pencolor("#de8891") 244 | fd(40) 245 | 246 | penup() 247 | goto(-5, -170) 248 | pendown() 249 | seth(-180) 250 | pensize(8) 251 | pencolor("#de8891") 252 | fd(35) 253 | 254 | 255 | def guest(x, y, z): 256 | penup() 257 | goto(x, y) 258 | seth(-z) 259 | pendown() 260 | for angel in range(5): 261 | fd(10) 262 | right(10) 263 | 264 | 265 | def guet(x, y, z): 266 | penup() 267 | goto(x, y) 268 | seth(-z) 269 | pendown() 270 | for angel in range(5): 271 | fd(10) 272 | left(10) 273 | 274 | 275 | def qu(x, y, z): 276 | penup() 277 | goto(x, y) 278 | seth(-z) 279 | pendown() 280 | for angel in range(5): 281 | fd(6) 282 | right(10) 283 | seth(-150) 284 | fd(20) 285 | 286 | 287 | # 树枝 288 | guest(-70, -150, 160) 289 | guest(100, -150, 160) 290 | guet(110, -110, 50) 291 | guest(160, -140, 150) 292 | qu(80, -120, 180) 293 | guest(70, -85, 165) 294 | guest(-40, -85, 165) 295 | guet(90, -50, 50) 296 | guest(130, -80, 150) 297 | pencolor("pink") 298 | qu(-40, -60, 180) 299 | pencolor('#de8891') 300 | qu(80, -30, 180) 301 | pencolor("pink") 302 | qu(40, 10, 180) 303 | pencolor("#de8891") 304 | guest(-60, 30, 120) 305 | guest(-20, -20, 150) 306 | guet(45, 40, 60) 307 | guest(-30, 40, 170) 308 | guest(-30, 110, 115) 309 | guet(40, 90, 60) 310 | guest(80, 50, 160) 311 | pencolor("#de8891") 312 | 313 | 314 | def hdj(x, y): 315 | penup() 316 | goto(x, y) 317 | seth(80) 318 | pendown() 319 | pensize(2) 320 | circle(5) 321 | seth(10) 322 | fd(15) 323 | seth(120) 324 | fd(20) 325 | seth(240) 326 | fd(20) 327 | seth(180) 328 | fd(20) 329 | seth(-60) 330 | fd(20) 331 | seth(50) 332 | fd(20) 333 | seth(-40) 334 | fd(30) 335 | seth(-130) 336 | fd(5) 337 | seth(135) 338 | fd(30) 339 | seth(-60) 340 | fd(30) 341 | seth(-150) 342 | fd(6) 343 | seth(110) 344 | fd(30) 345 | 346 | 347 | def uit(x, y): 348 | penup() 349 | goto(x, y) 350 | pendown() 351 | pensize(2) 352 | circle(5) 353 | seth(-10) 354 | fd(15) 355 | seth(90) 356 | fd(15) 357 | seth(200) 358 | fd(15) 359 | seth(160) 360 | fd(15) 361 | seth(-90) 362 | fd(15) 363 | seth(10) 364 | fd(15) 365 | seth(-60) 366 | fd(20) 367 | seth(-180) 368 | fd(5) 369 | seth(110) 370 | fd(20) 371 | seth(-90) 372 | fd(20) 373 | seth(-180) 374 | fd(6) 375 | seth(70) 376 | fd(15) 377 | hideturtle() 378 | 379 | 380 | def yut(x, y, z): 381 | penup() 382 | goto(x, y) 383 | pendown() 384 | seth(z) 385 | for po in range(5): 386 | fd(4) 387 | left(36) 388 | 389 | 390 | def ytu(x, y, z): 391 | penup() 392 | goto(x, y) 393 | pendown() 394 | seth(z) 395 | for kk in range(5): 396 | fd(4) 397 | left(36) 398 | 399 | 400 | # 小蝴蝶结 401 | seth(0) 402 | uit(40, -160) 403 | hdj(-80, -120) 404 | yut(-67, -115, 120) 405 | yut(-86, -123, 150) 406 | hdj(40, -50) 407 | yut(52, -45, 130) 408 | yut(34, -55, 160) 409 | seth(0) 410 | uit(-20, -60) 411 | ytu(-4, -60, 100) 412 | ytu(-20, -60, 120) 413 | hdj(-30, 20) 414 | yut(-15, 25, 130) 415 | yut(-40, 20, 180) 416 | uit(30, 70) 417 | ytu(45, 70, 100) 418 | ytu(30, 70, 120) 419 | 420 | # 大蝴蝶结 421 | pencolor("#f799e6") 422 | pensize(5) 423 | penup() 424 | seth(0) 425 | goto(0, 150) 426 | pendown() 427 | circle(10) 428 | seth(-15) 429 | fd(40) 430 | seth(90) 431 | fd(40) 432 | seth(200) 433 | fd(40) 434 | seth(160) 435 | fd(40) 436 | seth(-90) 437 | fd(40) 438 | seth(15) 439 | fd(40) 440 | seth(-70) 441 | pencolor("#f799e6") 442 | pensize(4) 443 | fd(40) 444 | seth(-180) 445 | fd(10) 446 | seth(100) 447 | fd(40) 448 | seth(-100) 449 | fd(40) 450 | seth(-180) 451 | fd(10) 452 | seth(70) 453 | fd(40) 454 | penup() 455 | seth(0) 456 | goto(0, 130) 457 | pencolor("pink") 458 | pendown() 459 | 460 | 461 | def iou(x, y, z): 462 | penup() 463 | goto(x, y) 464 | pencolor("#f799e6") 465 | pendown() 466 | seth(z) 467 | for po in range(10): 468 | fd(4) 469 | left(18) 470 | 471 | 472 | seth(0) 473 | iou(35, 145, 100) 474 | iou(-7, 145, 110) 475 | pencolor("red") 476 | pensize(7) 477 | penup() 478 | goto(-35, 135) 479 | pendown() 480 | 481 | # 圣诞帽 482 | seth(-20) 483 | pensize(2) 484 | penup() 485 | goto(-30, -120) 486 | pencolor("black") 487 | pendown() 488 | fillcolor("red") 489 | fd(30) 490 | circle(4, 180) 491 | fd(30) 492 | circle(4, 180) 493 | penup() 494 | goto(-25, -115) 495 | seth(75) 496 | pendown() 497 | begin_fill() 498 | for i in range(5): 499 | fd(6) 500 | right(20) 501 | seth(-10) 502 | for i in range(5): 503 | fd(8) 504 | right(15) 505 | seth(145) 506 | for i in range(5): 507 | fd(5) 508 | left(2) 509 | seth(90) 510 | for i in range(5): 511 | fd(1) 512 | left(2) 513 | seth(-90) 514 | for i in range(4): 515 | fd(4) 516 | right(6) 517 | seth(161) 518 | fd(30) 519 | end_fill() 520 | pensize(1) 521 | pencolor("black") 522 | 523 | 524 | def koc(x, y, size): 525 | pensize(2) 526 | pencolor("black") 527 | penup() 528 | goto(x, y) 529 | pendown() 530 | begin_fill() 531 | fillcolor("yellow") 532 | for i in range(5): 533 | left(72) 534 | fd(size) 535 | right(144) 536 | fd(size) 537 | end_fill() 538 | 539 | 540 | # 星星 541 | seth(-15) 542 | koc(-120, -70, 10) 543 | seth(10) 544 | koc(100, -20, 10) 545 | seth(-10) 546 | koc(10, 40, 10) 547 | seth(30) 548 | koc(-80, 60, 10) 549 | koc(100, -150, 10) 550 | koc(-140, -150, 10) 551 | koc(20, 120, 10) 552 | 553 | # 袜子 554 | seth(-20) 555 | pensize(2) 556 | penup() 557 | goto(-20, 80) 558 | pencolor("black") 559 | pendown() 560 | fillcolor("red") 561 | fd(25) 562 | circle(4, 180) 563 | fd(25) 564 | circle(4, 180) 565 | penup() 566 | goto(-15, 80) 567 | pendown() 568 | begin_fill() 569 | fillcolor("red") 570 | seth(-120) 571 | fd(20) 572 | seth(150) 573 | fd(5) 574 | circle(7, 180) 575 | fd(15) 576 | circle(5, 90) 577 | fd(30) 578 | seth(160) 579 | fd(18) 580 | end_fill() 581 | penup() 582 | seth(0) 583 | goto(100, -230) 584 | pendown() 585 | write("Merry Christmas", align="right", font=("Comic Sans MS", 24, "bold")) 586 | done() 587 | 588 | -------------------------------------------------------------------------------- /Python版/ChristmasTree04_Green.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | import time 3 | 4 | setup(500, 500, startx=None, starty=None) 5 | speed(0) 6 | pencolor("#008500") 7 | pensize(10) 8 | penup() 9 | hideturtle() 10 | goto(0, 150) 11 | showturtle() 12 | pendown() 13 | shape(name="classic") 14 | # 1 15 | seth(-120) 16 | for i in range(10): 17 | fd(12) 18 | right(2) 19 | penup() 20 | goto(0, 150) 21 | seth(-60) 22 | pendown() 23 | for i in range(10): 24 | fd(12) 25 | left(2) 26 | seth(-150) 27 | penup() 28 | fd(10) 29 | pendown() 30 | for i in range(5): 31 | fd(10) 32 | right(15) 33 | seth(-150) 34 | penup() 35 | fd(8) 36 | pendown() 37 | for i in range(5): 38 | fd(10) 39 | right(15) 40 | seth(-155) 41 | penup() 42 | fd(5) 43 | pendown() 44 | for i in range(5): 45 | fd(7) 46 | right(15) 47 | # 2 48 | penup() 49 | goto(-55, 34) 50 | pendown() 51 | seth(-120) 52 | for i in range(10): 53 | fd(8) 54 | right(5) 55 | 56 | penup() 57 | goto(50, 35) 58 | seth(-60) 59 | pendown() 60 | for i in range(10): 61 | fd(8) 62 | left(5) 63 | seth(-120) 64 | penup() 65 | fd(10) 66 | seth(-145) 67 | pendown() 68 | for i in range(5): 69 | fd(10) 70 | right(15) 71 | penup() 72 | fd(10) 73 | seth(-145) 74 | pendown() 75 | for i in range(5): 76 | fd(12) 77 | right(15) 78 | penup() 79 | fd(8) 80 | seth(-145) 81 | pendown() 82 | for i in range(5): 83 | fd(10) 84 | right(15) 85 | penup() 86 | seth(-155) 87 | fd(8) 88 | pendown() 89 | for i in range(5): 90 | fd(11) 91 | right(15) 92 | # 3 93 | penup() 94 | goto(-100, -40) 95 | seth(-120) 96 | pendown() 97 | for i in range(10): 98 | fd(6) 99 | right(3) 100 | penup() 101 | goto(80, -39) 102 | seth(-50) 103 | pendown() 104 | for i in range(10): 105 | fd(6) 106 | left(3) 107 | seth(-155) 108 | penup() 109 | fd(10) 110 | pendown() 111 | for i in range(5): 112 | fd(8) 113 | right(10) 114 | penup() 115 | fd(8) 116 | seth(-145) 117 | pendown() 118 | for i in range(7): 119 | fd(8) 120 | right(10) 121 | penup() 122 | fd(8) 123 | seth(-145) 124 | pendown() 125 | for i in range(7): 126 | fd(7) 127 | right(10) 128 | penup() 129 | fd(8) 130 | seth(-145) 131 | pendown() 132 | for i in range(7): 133 | fd(7) 134 | right(10) 135 | penup() 136 | fd(8) 137 | seth(-140) 138 | pendown() 139 | for i in range(7): 140 | fd(6) 141 | right(10) 142 | 143 | # 4 144 | penup() 145 | goto(-120, -95) 146 | seth(-130) 147 | pendown() 148 | for i in range(7): 149 | fd(10) 150 | right(5) 151 | penup() 152 | goto(100, -95) 153 | seth(-50) 154 | pendown() 155 | for i in range(7): 156 | fd(10) 157 | left(5) 158 | penup() 159 | seth(-120) 160 | fd(10) 161 | seth(-155) 162 | pendown() 163 | for i in range(6): 164 | fd(8) 165 | right(10) 166 | penup() 167 | seth(-160) 168 | fd(10) 169 | seth(-155) 170 | pendown() 171 | for i in range(6): 172 | fd(8) 173 | right(10) 174 | penup() 175 | seth(-160) 176 | fd(10) 177 | seth(-155) 178 | pendown() 179 | for i in range(6): 180 | fd(8) 181 | right(10) 182 | penup() 183 | seth(-160) 184 | fd(10) 185 | seth(-160) 186 | pendown() 187 | for i in range(6): 188 | fd(8) 189 | right(10) 190 | penup() 191 | seth(-160) 192 | fd(10) 193 | seth(-160) 194 | pendown() 195 | for i in range(6): 196 | fd(8) 197 | right(10) 198 | penup() 199 | seth(-160) 200 | fd(10) 201 | seth(-165) 202 | pendown() 203 | for i in range(5): 204 | fd(10) 205 | right(11) 206 | # 5 207 | penup() 208 | goto(-70, -165) 209 | seth(-85) 210 | pendown() 211 | for i in range(3): 212 | fd(5) 213 | left(3) 214 | penup() 215 | goto(70, -165) 216 | seth(-95) 217 | pendown() 218 | for i in range(3): 219 | fd(5) 220 | right(3) 221 | seth(-170) 222 | penup() 223 | fd(10) 224 | pendown() 225 | pendown() 226 | for i in range(10): 227 | fd(12) 228 | right(2) 229 | # 6 230 | penup() 231 | goto(70, -165) 232 | pendown() 233 | seth(-90) 234 | pensize(8) 235 | pencolor("#00cc00") 236 | circle(-20, 90) 237 | 238 | penup() 239 | goto(30, -185) 240 | pendown() 241 | seth(-180) 242 | pensize(8) 243 | pencolor("#00cc00") 244 | fd(40) 245 | 246 | penup() 247 | goto(-5, -170) 248 | pendown() 249 | seth(-180) 250 | pensize(8) 251 | pencolor("#00cc00") 252 | fd(35) 253 | 254 | 255 | def guest(x, y, z): 256 | penup() 257 | goto(x, y) 258 | seth(-z) 259 | pendown() 260 | for angel in range(5): 261 | fd(10) 262 | right(10) 263 | 264 | 265 | def guet(x, y, z): 266 | penup() 267 | goto(x, y) 268 | seth(-z) 269 | pendown() 270 | for angel in range(5): 271 | fd(10) 272 | left(10) 273 | 274 | 275 | def qu(x, y, z): 276 | penup() 277 | goto(x, y) 278 | seth(-z) 279 | pendown() 280 | for angel in range(5): 281 | fd(6) 282 | right(10) 283 | seth(-150) 284 | fd(20) 285 | 286 | 287 | # 树枝 288 | guest(-70, -150, 160) 289 | guest(100, -150, 160) 290 | guet(110, -110, 50) 291 | guest(160, -140, 150) 292 | qu(80, -120, 180) 293 | guest(70, -85, 165) 294 | guest(-40, -85, 165) 295 | guet(90, -50, 50) 296 | guest(130, -80, 150) 297 | pencolor("#00cc00") 298 | qu(-40, -60, 180) 299 | pencolor('#00cc00') 300 | qu(80, -30, 180) 301 | pencolor("#00cc00") 302 | qu(40, 10, 180) 303 | pencolor("#00cc00") 304 | guest(-60, 30, 120) 305 | guest(-20, -20, 150) 306 | guet(45, 40, 60) 307 | guest(-30, 40, 170) 308 | guest(-30, 110, 115) 309 | guet(40, 90, 60) 310 | guest(80, 50, 160) 311 | pencolor("red") 312 | 313 | 314 | def hdj(x, y): 315 | penup() 316 | goto(x, y) 317 | seth(80) 318 | pendown() 319 | pensize(2) 320 | circle(5) 321 | seth(10) 322 | fd(15) 323 | seth(120) 324 | fd(20) 325 | seth(240) 326 | fd(20) 327 | seth(180) 328 | fd(20) 329 | seth(-60) 330 | fd(20) 331 | seth(50) 332 | fd(20) 333 | seth(-40) 334 | fd(30) 335 | seth(-130) 336 | fd(5) 337 | seth(135) 338 | fd(30) 339 | seth(-60) 340 | fd(30) 341 | seth(-150) 342 | fd(6) 343 | seth(110) 344 | fd(30) 345 | 346 | 347 | def uit(x, y): 348 | penup() 349 | goto(x, y) 350 | pendown() 351 | pensize(2) 352 | circle(5) 353 | seth(-10) 354 | fd(15) 355 | seth(90) 356 | fd(15) 357 | seth(200) 358 | fd(15) 359 | seth(160) 360 | fd(15) 361 | seth(-90) 362 | fd(15) 363 | seth(10) 364 | fd(15) 365 | seth(-60) 366 | fd(20) 367 | seth(-180) 368 | fd(5) 369 | seth(110) 370 | fd(20) 371 | seth(-90) 372 | fd(20) 373 | seth(-180) 374 | fd(6) 375 | seth(70) 376 | fd(15) 377 | hideturtle() 378 | 379 | 380 | def yut(x, y, z): 381 | penup() 382 | goto(x, y) 383 | pendown() 384 | seth(z) 385 | for po in range(5): 386 | fd(4) 387 | left(36) 388 | 389 | 390 | def ytu(x, y, z): 391 | penup() 392 | goto(x, y) 393 | pendown() 394 | seth(z) 395 | for kk in range(5): 396 | fd(4) 397 | left(36) 398 | 399 | 400 | # 小蝴蝶结 401 | seth(0) 402 | uit(40, -160) 403 | hdj(-80, -120) 404 | yut(-67, -115, 120) 405 | yut(-86, -123, 150) 406 | hdj(40, -50) 407 | yut(52, -45, 130) 408 | yut(34, -55, 160) 409 | seth(0) 410 | pencolor("pink") 411 | uit(-20, -60) 412 | ytu(-4, -60, 100) 413 | ytu(-20, -60, 120) 414 | hdj(-30, 20) 415 | yut(-15, 25, 130) 416 | yut(-40, 20, 180) 417 | uit(30, 70) 418 | ytu(45, 70, 100) 419 | ytu(30, 70, 120) 420 | 421 | # 大蝴蝶结 422 | pencolor("yellow") 423 | pensize(5) 424 | penup() 425 | seth(0) 426 | goto(0, 150) 427 | pendown() 428 | circle(10) 429 | seth(-15) 430 | fd(40) 431 | seth(90) 432 | fd(40) 433 | seth(200) 434 | fd(40) 435 | seth(160) 436 | fd(40) 437 | seth(-90) 438 | fd(40) 439 | seth(15) 440 | fd(40) 441 | seth(-70) 442 | pencolor("yellow") 443 | pensize(4) 444 | fd(40) 445 | seth(-180) 446 | fd(10) 447 | seth(100) 448 | fd(40) 449 | seth(-100) 450 | fd(40) 451 | seth(-180) 452 | fd(10) 453 | seth(70) 454 | fd(40) 455 | penup() 456 | seth(0) 457 | goto(0, 130) 458 | pencolor("yellow") 459 | pendown() 460 | 461 | 462 | def iou(x, y, z): 463 | penup() 464 | goto(x, y) 465 | pencolor("yellow") 466 | pendown() 467 | seth(z) 468 | for po in range(10): 469 | fd(4) 470 | left(18) 471 | 472 | 473 | seth(0) 474 | iou(35, 145, 100) 475 | iou(-7, 145, 110) 476 | pencolor("red") 477 | pensize(7) 478 | penup() 479 | goto(-35, 135) 480 | pendown() 481 | 482 | # 圣诞帽 483 | seth(-20) 484 | pensize(2) 485 | penup() 486 | goto(-30, -120) 487 | pencolor("black") 488 | pendown() 489 | fillcolor("red") 490 | fd(30) 491 | circle(4, 180) 492 | fd(30) 493 | circle(4, 180) 494 | penup() 495 | goto(-25, -115) 496 | seth(75) 497 | pendown() 498 | begin_fill() 499 | for i in range(5): 500 | fd(6) 501 | right(20) 502 | seth(-10) 503 | for i in range(5): 504 | fd(8) 505 | right(15) 506 | seth(145) 507 | for i in range(5): 508 | fd(5) 509 | left(2) 510 | seth(90) 511 | for i in range(5): 512 | fd(1) 513 | left(2) 514 | seth(-90) 515 | for i in range(4): 516 | fd(4) 517 | right(6) 518 | seth(161) 519 | fd(30) 520 | end_fill() 521 | pensize(1) 522 | pencolor("black") 523 | 524 | 525 | def koc(x, y, size): 526 | pensize(2) 527 | pencolor("black") 528 | penup() 529 | goto(x, y) 530 | pendown() 531 | begin_fill() 532 | fillcolor("yellow") 533 | for i in range(5): 534 | left(72) 535 | fd(size) 536 | right(144) 537 | fd(size) 538 | end_fill() 539 | 540 | 541 | # 星星 542 | seth(-15) 543 | koc(-120, -70, 10) 544 | seth(10) 545 | koc(100, -20, 10) 546 | seth(-10) 547 | koc(10, 40, 10) 548 | seth(30) 549 | koc(-80, 60, 10) 550 | koc(100, -150, 10) 551 | koc(-140, -150, 10) 552 | koc(20, 120, 10) 553 | 554 | # 袜子 555 | seth(-20) 556 | pensize(2) 557 | penup() 558 | goto(-20, 80) 559 | pencolor("black") 560 | pendown() 561 | fillcolor("red") 562 | fd(25) 563 | circle(4, 180) 564 | fd(25) 565 | circle(4, 180) 566 | penup() 567 | goto(-15, 80) 568 | pendown() 569 | begin_fill() 570 | fillcolor("red") 571 | seth(-120) 572 | fd(20) 573 | seth(150) 574 | fd(5) 575 | circle(7, 180) 576 | fd(15) 577 | circle(5, 90) 578 | fd(30) 579 | seth(160) 580 | fd(18) 581 | end_fill() 582 | penup() 583 | seth(0) 584 | goto(100, -230) 585 | pendown() 586 | write("Happy Merry Christmas ", align="center", font=("Comic Sans MS", 24, "bold")) 587 | done() 588 | --------------------------------------------------------------------------------