python粒子圣诞树
时间: 2023-12-22 20:30:16 浏览: 105
(python)圣诞树
以下是一个使用Python绘制粒子圣诞树的例子:
```python
import turtle
from random import randint
# 设置画布
turtle.setup(800, 600)
turtle.bgcolor("black")
# 定义绘制雪花的函数
def drawSnow():
turtle.hideturtle()
turtle.speed(0)
turtle.pencolor("white")
turtle.pensize(2)
for i in range(80): # 雪花数量
turtle.goto(randint(-248, 248), randint(-100, 248))
petalNumber = 6 # 雪花花瓣数为6
snowSize = int(randint(2, 10))
for j in range(petalNumber):
turtle.fd(snowSize)
turtle.backward(snowSize)
turtle.right(360/petalNumber)
# 绘制圣诞树
def drawChristmasTree():
turtle.penup()
turtle.goto(-100, -200)
turtle.pendown()
turtle.color("green")
turtle.begin_fill()
turtle.left(75)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right(150)
turtle.forward(150)
turtle.left(150)
turtle.forward(150)
turtle.right
阅读全文