前言
希望放烟花的人跟看烟花的人都能平平安安。
???? NICE TO MEET YOU :)????
所有文章完整的素材+源码都在????????
哈喽!我是木子,新的一年祝大家所求皆如愿,所行化坦途,多喜乐,长安宁。
2023兔年——兔飞猛进,兔步青云,前兔无量,扬眉兔气,前兔似锦,大展宏兔
玉兔呈祥,兔出贡献,兔围而出,谈兔不凡,兔谋大业,兔飞猛进,兔步青云,宏兔大志!
今天给给大家写一些新年的代码送给大家,喜欢的点点三连哦~????????
正文
一、烟画许愿
????我对着烟花许愿,希望你诸邪避退,百事无忌,平安喜乐,万事如意。
????我对着烟火许愿,希望你永远在我身边。
????希望新春的烟火可以带来好多好多的好消息。
????如果你也刚好看到烟花,就当我们见过面吧。
????浪漫的不是烟花,而是和你一起看烟花的人。
1)烟花盛开代码
import pygame
from random import randint, uniform, choice
import math
#===========首先设置全局变量====================
vector = pygame.math.Vector2
# 重力变量
gravity = vector(0, 0.3)
# 控制窗口的大小
DISPLAY_WIDTH = DISPLAY_HEIGHT = 800
# 颜色选项
trail_colours = [(45, 45, 45), (60, 60, 60), (75, 75, 75), (125, 125, 125), (150, 150, 150)]
dynamic_offset = 1
static_offset = 3
#=======Firework : 整体部分;================
class Firework:
def __init__(self):
# 随机颜色
self.colour = (randint(0, 255), randint(0, 255), randint(0, 255))
self.colours = (
(randint(0, 255), randint(0, 255), randint(0, 255)),
(randint(0, 255), randint(0, 255), randint(0, 255)),
(randint(0, 255), randint(0, 255), randint(0, 255)))
self.firework = Particle(randint(0, DISPLAY_WIDTH), DISPLAY_HEIGHT, True,
self.colour) # Creates the firework particle
self.exploded = False
self.particles = []
self.min_max_particles = vector(100, 225)
def update(self, win): # 每帧调用
if not self.exploded:
self.firework.apply_force(gravity)
self.firework.move()
for tf in self.firework.trails:
tf.show(win)
self.show(win)
if self.firework.vel.y >= 0:
self.exploded = True
self.explode()
else:
for particle in self.particles:
particle.apply_force(vector(gravity.x + uniform(-1, 1) / 20, gravity.y / 2 + (randint(1, 8) / 100)))
particle.move()
for t in particle.trails:
t.show(win)
particle.show(win)
def explode(self):
# amount 数量
amount = randint(self.min_max_particles.x, self.min_max_particles.y)
for i in range(amount):
self.particles.append(Particle(self.firework.pos.x, self.firework.pos.y, False, self.colours))
def show(self, win):
pygame.draw.circle(win, self.colour, (int(self.firework.pos.x), int(self.firework.pos.y)), self.firework.size)
def remove(self):
if self.exploded:
for p in self.particles:
if p.remove is True:
self.particles.remove(p)
if len(self.particles) == 0:
return True
else:
return False
#================Particle:烟花粒子(包含轨迹)======================
class Particle:
def __init__(self, x, y, firework, colour):
self.firework = firework
self.pos = vector(x, y)
self.origin = vector(x, y)
self.radius = 20
self.remove = False
self.explosion_radius = randint(5, 18)
self.life = 0
self.acc = vector(0, 0)
# trail variables
self.trails = [] # stores the particles trail objects
self.prev_posx = [-10] * 10 # stores the 10 last positions
self.prev_posy = [-10] * 10 # stores the 10 last positions
if self.firework:
self.vel = vector(0, -randint(17, 20))
self.size = 5
self.colour = colour
for i in range(5):
self.trails.append(Trail(i, self.size, True))
else:
self.vel = vector(uniform(-1, 1), uniform(-1, 1))
self.vel.x *= randint(7, self.explosion_radius + 2)
self.vel.y *= randint(7, self.explosion_radius + 2)
# 向量
self.size = randint(2, 4)
self.colour = choice(colour)
# 5 个 tails总计
for i in range(5):
self.trails.append(Trail(i, self.size, False))
def apply_force(self, force):
self.acc += force
def move(self):
if not self.firework:
self.vel.x *= 0.8
self.vel.y *= 0.8
self.vel += self.acc
self.pos += self.vel
self.acc *= 0
if self.life == 0 and not self.firework: # 检查粒子的爆炸范围
distance = math.sqrt((self.pos.x - self.origin.x) ** 2 + (self.pos.y - self.origin.y) ** 2)
if distance > self.explosion_radius:
self.remove = True
self.decay()
self.trail_update()
self.life += 1
def show(self, win):
pygame.draw.circle(win, (self.colour[0], self.colour[1], self.colour[2], 0), (int(self.pos.x), int(self.pos.y)),
self.size)
def decay(self): # random decay of the particles
if 50 > self.life > 10: # early stage their is a small chance of decay
ran = randint(0, 30)
if ran == 0:
self.remove = True
elif self.life > 50:
ran = randint(0, 5)
if ran == 0:
self.remove = True
def trail_update(self):
self.prev_posx.pop()
self.prev_posx.insert(0, int(self.pos.x))
self.prev_posy.pop()
self.prev_posy.insert(0, int(self.pos.y))
for n, t in enumerate(self.trails):
if t.dynamic:
t.get_pos(self.prev_posx[n + dynamic_offset], self.prev_posy[n + dynamic_offset])
else:
t.get_pos(self.prev_posx[n + static_offset], self.prev_posy[n + static_offset])
#=======Trail:烟花轨迹,本质上是一个点 。创建 Trail 类,定义 show 方法绘制轨迹 、get_pos 实时获取轨迹坐标====
class Trail:
def __init__(self, n, size, dynamic):
self.pos_in_line = n
self.pos = vector(-10, -10)
self.dynamic = dynamic
if self.dynamic:
self.colour = trail_colours[n]
self.size = int(size - n / 2)
else:
self.colour = (255, 255, 200)
self.size = size - 2
if self.size < 0:
self.size = 0
def get_pos(self, x, y):
self.pos = vector(x, y)
def show(self, win):
pygame.draw.circle(win, self.colour, (int(self.pos.x), int(self.pos.y)), self.size)
def update(win, fireworks):
for fw in fireworks:
fw.update(win)
if fw.remove():
fireworks.remove(fw)
pygame.display.update()
#=======================主函数=======================
def main():
pygame.init()
pygame.font.init()
pygame.display.set_caption("祝您新年快乐") # 标题
background = pygame.image.load("./5.png") # 背景
sound_wav = pygame.mixer.music.load("2.mp3")
pygame.mixer.music.play()
pygame.init()
# 加载背景音乐
'''pygame.mixer.music.load("./res/音乐文件名")
# 循环播放背景音乐
pygame.mixer.music.play(-1)
# 停止背景音乐
pygame.mixer.music.stop()
# 加载音效
boom_sound = pygame.mixer.Sound("./res/音效名")
# 播放音效
boom_sound.play()
boom_sound.stop()
myfont = pygame.font.Font("simkai.TTF", 80)
myfont1 = pygame.font.Font("simkai.ttf", 30)
testsurface = myfont.render("虎虎生威", False, (0, 0, 0), (220, 20, 60))
testsurface1 = myfont1.render("", False, (251, 59, 85))'''
# pygame.image.load("")
win = pygame.display.set_mode((DISPLAY_WIDTH, DISPLAY_HEIGHT))
# win.blit(background)
clock = pygame.time.Clock()
fireworks = [Firework() for i in range(2)] # create the first fireworks
running = True
while running:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if event.type == pygame.KEYDOWN: # Change game speed with number keys
if event.key == pygame.K_1: # 按下 1
fireworks.append(Firework())
if event.key == pygame.K_2: # 按下 2 加入10个烟花
for i in range(10):
fireworks.append(Firework())
if event.key == pygame.K_3: # 按下 3 加入100个烟花
for i in range(100):
fireworks.append(Firework())
win.fill((20, 20, 30)) # draw background
#win.blit(background, (0, 0))
#win.blit(testsurface, (200, 30))
#win.blit(testsurface1, (520, 80))
if randint(0, 20) == 1: # 创建新的烟花
fireworks.append(Firework())
update(win, fireworks)
pygame.quit()
quit()
2)效果展示
随机截图——
随机截图——
二、新年烟花
????烟花和你都嘎嘎浪漫。
????凑不够满天星辰,那就放烟花给你看。
????烟花和喜欢的人看才嘎嘎浪漫。
????希望接下来的日子像烟花一样灿烂。
????新年的烟花那么响,也没有我想你那么想。
1)烟花表白代码
import random
import pygame as py
import tkinter as tk
from time import time, sleep
from tkinter import filedialog
from PIL import Image, ImageTk
from math import sin, cos, radians
from random import choice, uniform, randint
#导入库
def randomcolor():
#生成随机颜色
colArr = ['1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
color = ""
for i in range(6):
color += colArr[random.randint(0,14)]
return "#"+color
GRAVITY = 0.06
#重力变量
colors = ['red', 'blue', 'yellow', 'white', 'green', 'orange', 'purple', 'seagreen','indigo', 'cornflowerblue', 'pink']
#颜色列表
'''
Generic class for particles
particles are emitted almost randomly on the sky, forming a round of circle (a star) before falling and getting removed
from canvas
Attributes(属性):
- id: 粒子的id
- x, y: 粒子的坐标
- vx, vy: 粒子在对应坐标的变化速度
- total:一颗烟花里的粒子总数
- age: 粒子在画布上停留的时间
- color: 自我移植
- cv: 画布
- lifespan: 粒子在画布上停留的时间
'''
class part:
#为每一个烟花绽放出来的粒子单独构建一个类的对象 ,每个粒子都会有一些重要的属性,决定它的外观(大小、颜色)、移动速度等
def __init__(self, cv, idx, total, explosion_speed, x=0., y=0., vx = 0., vy = 0., size=2., color = 'red', lifespan = 2, **kwargs):
self.id = idx
#每个烟花的特定标识符
self.x = x
#烟花绽放x轴
self.y = y
#烟花绽放y轴
self.initial_speed = explosion_speed
#粒子初始速度
self.vx = vx
#粒子运动x轴速度
self.vy = vy
#粒子运动y轴速度
self.total = total
#绽放粒子数
self.age = 0
#粒子已停留时间
self.color = color
#粒子颜色
self.cv = cv
#画布
self.cid = self.cv.create_oval(x - size, y - size, x + size,y + size, fill=self.color, outline='white',width=0.01)
#指定一个限定矩形(Tkinter 会自动在这个矩形内绘制一个椭圆)
self.lifespan = lifespan
#粒子在画布上停留的时间
def update(self, dt):
self.age += dt
#更新粒子停留时间
if self.alive() and self.expand():
#如果粒子既存活又处于扩张阶段
move_x = cos(radians(self.id*360/self.total))*self.initial_speed
#粒子x轴继续膨胀
move_y = sin(radians(self.id*360/self.total))*self.initial_speed
#粒子y轴继续膨胀
self.cv.move(self.cid, move_x, move_y)
#根据id把画布上的粒子移动x和y个距离
self.vx = move_x/(float(dt)*1000)
#粒子x轴的速度
elif self.alive():
columnFont = ('华文行楷',14)
#如果粒子仅存活不扩张(只是停留时间足够,说明膨胀到最大了),则*坠落
self.cv.create_text(250, 100, text='三',tag="write_tag", fill=choice(colors),font = columnFont) #字体
self.cv.create_text(300, 100, text='生',tag="write_tag", fill=choice(colors),font = columnFont)
self.cv.create_text(350, 100, text='烟',tag="write_tag", fill=choice(colors),font = columnFont)
self.cv.create_text(400, 100, text='火',tag="write_tag", fill=choice(colors),font = columnFont)
#删除文字标签
move_x = cos(radians(self.id*360/self.total))
#x轴的移动位移
# we technically don't need to update x, y because move will do the job
self.cv.move(self.cid, self.vx + move_x, self.vy+GRAVITY*dt)
self.vy += GRAVITY*dt
#更新y轴
elif self.cid is not None:
#如果粒子生命周期已过,则将其移除
cv.delete(self.cid)
#在画布上移除该粒子对象
self.cv.delete("write_tag")
#同时移除字体
self.cid = None
def expand (self):
#定义膨胀效果时间帧
return self.age <= 1.2
#判断膨胀时间是否小于1.2秒
def alive(self):
#判断粒子是否仍在生命周期内
return self.age <= self.lifespan
#判断已停留时间是否小于应该停留时间
'''
Firework simulation loop:
Recursively call to repeatedly emit new fireworks on canvas
a list of list (list of stars, each of which is a list of particles)
is created and drawn on canvas at every call,
via update protocol inside each 'part' object
'''
def simulate(cv):
t = time()
#返回自1970年后经过的浮点秒数,精确到小数点后7位
explode_points = []
#爆炸点列表,烟花列表
wait_time = randint(10,100)
#等待时间为10到100之间整数
numb_explode = randint(8,20)
#爆炸烟花个数时6到10之间的随机整数
# create list of list of all particles in all simultaneous explosion
for point in range(numb_explode):
#为所有模拟烟花绽放的全部粒子创建一列列表
if point<=4:
objects = []
#每个点的爆炸粒子列表粒子列表
x_cordi = 250 + point*50
#每个爆炸点的x轴
y_cordi = 100
#每个爆炸点的y轴
speed = uniform (0.5, 1.5)
#每个爆炸点的速度
size = uniform (0.5,3)
#每个爆炸点的大小
color = choice(colors)
#每个爆炸点的颜色
explosion_speed = uniform(0.6, 3)
#爆炸的绽放速度
total_particles = randint(10,60)
#烟花的总粒子数
for i in range(1,total_particles):
#同一个烟花爆炸出来的粒子大小、速度、坐标都是相同的
r = part(cv, idx = i, total = total_particles, explosion_speed = explosion_speed, x = x_cordi, y = y_cordi, vx = speed, vy = speed, color=color, size = size, lifespan = uniform(0.6,1.75))
#把上述参数代入part函数,但是每个粒子的生存时间是自己独立的
objects.append(r)
#把r添加进粒子列表
explode_points.append(objects)
#把粒子列表添加进烟花列表
else:
objects = []
#每个点的爆炸粒子列表粒子列表
x_cordi = randint(50,550)
#每个爆炸点的x轴
y_cordi = randint(50, 150)
#每个爆炸点的y轴
speed = uniform (0.5, 1.5)
#每个爆炸点的速度
size = uniform (0.5,3)
#每个爆炸点的大小
color = choice(colors)
#每个爆炸点的颜色
explosion_speed = uniform(0.3, 2)
#爆炸的绽放速度
total_particles = randint(10,50)
#烟花的总粒子数
for i in range(1,total_particles):
#同一个烟花爆炸出来的粒子大小、速度、坐标都是相同的
r = part(cv, idx = i, total = total_particles, explosion_speed = explosion_speed, x = x_cordi, y = y_cordi, vx = speed, vy = speed, color=color, size = size, lifespan = uniform(0.6,1.75))
#把上述参数代入part函数,但是每个粒子的生存时间是自己独立的
objects.append(r)
#把r添加进粒子列表
explode_points.append(objects)
#把粒子列表添加进烟花列表
total_time = .0
#初始化总时间
# keeps undate within a timeframe of 1.8 second
while total_time < 2:
#当总时间小于1.8秒时运行该循环
sleep(0.03)
#让画面暂停0.01秒
tnew = time()
#刷新时间
t, dt = tnew, tnew - t
#时间等于新时间,和上次时间间隔为tnew-t
for point in explode_points:
#遍历烟花列表
for item in point:
#遍历烟花里的粒子列表
item.update(dt)
#粒子更新时间
cv.update()
#刷新画布
total_time += dt
#为while循环增加时间
root.after(wait_time, simulate, cv)
#将组件置于其他组件之后,放在最顶层,覆盖下面的,递归调用自己,形成新一轮的爆炸
def close(*ignore):
#打开模拟循环并关闭窗口
"""Stops simulation loop and closes the window."""
global root
root.quit()
if __name__ == '__main__':
root = tk.Tk()
root.title('漫天烟花——祝大家—有情人终成眷属') # 设置窗体的标题栏
cv = tk.Canvas(root, height=600, width=600)
#绘制一个高600,宽600的画布
bgpath = filedialog.askopenfilename(title='请选择背景图片')
#选择背景图片
image = Image.open(bgpath)
#打开背景图片
image = image.resize((600,600), Image.ANTIALIAS)
#把背景图片调整成窗口大小
photo = ImageTk.PhotoImage(image)
cv.create_image(0, 0, image=photo, anchor='nw')
#在画布上绘制加载的背景图片
bgmusic = filedialog.askopenfilename(title='请选择背景音乐')
py.mixer.init()
# 初始化
py.mixer.music.load(bgmusic)
# 文件加载
py.mixer.music.play(-1, 0, fade_ms=50)
# 播放 第一个是播放值 -1代表循环播放, 第二个参数代表开始播放的时间
py.mixer.music.pause()
#暂停
py.mixer.music.unpause()
#取消暂停
cv.pack()
#把cv添加进去
root.protocol("WM_DELETE_WINDOW", close)
root.after(200, simulate, cv)
#在0.1秒后再调用stimulate函数,生成一轮烟花绽放效果
root.mainloop()
#执行root,生成窗口
2)效果展示
三、平平安安
????玫瑰花送谁都浪漫,烟花和谁看都好看,但和你就是双倍的浪漫。
????愿我们在烟花爆竹的光亮中成为澄清勇敢温柔的人。
????烟花盛开的时候,是我在想你。
????把愿望写在春联上,把思念留在烟花里。
????希望放烟花的人跟看烟花的人都能平平安安。
1)2023兔年吉祥代码
# coding=utf-8
"""
"""
from turtle import *
import time
def set_start(x, y, w=0.5, c='black'):
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 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='pink'):
set_start(x, y, 1, c=c)
forward(1)
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 draw_ear():
# 左侧耳朵
fill_color_patch(-50, 86, c='#9392B3')
begin_fill()
set_start(-50, 86, w=4, c='#9392B3')
right_rotate(1, 174, 10)
right_rotate(5, 5, 15)
right_rotate(4, 6, 15)
width(3)
right_rotate(2, 4, 13)
right_rotate(2, 5, 10)
left_rotate(3, 9, 12)
width(4)
right_rotate(1, 128, 10)
right_rotate(3, 9.5, 31)
right_rotate(5, 7, 25)
right_rotate(1, 80, 10)
left_rotate(3, 7, 12)
fillcolor('pink')
end_fill()
width(3)
right_rotate(1, 160, 5)
left_rotate(1, 20, 10)
left_rotate(3, 8, 20)
width(4)
left_rotate(1, 2, 15)
left_rotate(5, 5, 15)
left_rotate(4, 3, 15)
fill_color_patch(-35, 105, c='#E6E6FA')
begin_fill()
set_start(-35, 105, w=1, c='#E6E6FA')
right_rotate(1, 170, 10)
right_rotate(3, 8, 25)
right_rotate(3, 11, 23)
right_rotate(1, 130, 20)
right_rotate(5, 8, 25)
goto(-35, 105)
fillcolor('#E6E6FA')
end_fill()
fill_color_patch(-32, 110, c='#D6D2F6')
begin_fill()
set_start(-32, 110, w=1, c='#D6D2F6')
right_rotate(1, 170, 10)
right_rotate(3, 7, 23)
right_rotate(3, 11, 20)
right_rotate(1, 131, 20)
right_rotate(5, 8, 23)
goto(-32, 110)
fillcolor('#D6D2F6')
end_fill()
set_start(-48.87, 85.22, w=3, c='#9392B3')
setheading(195.67)
right_rotate(1, 160, 5)
left_rotate(1, 20, 10)
left_rotate(3, 8, 20)
width(4)
left_rotate(1, 2, 15)
left_rotate(5, 5, 15)
left_rotate(4, 3, 15)
# 右侧耳朵
fill_color_patch(90, 67, c='#9392B3')
begin_fill()
set_start(90, 67, w=4, c='#9392B3')
left_rotate(1, 180, 10)
left_rotate(3, 5, 13)
left_rotate(2, 8, 15)
left_rotate(3, 6, 15)
left_rotate(4, 5, 15)
right_rotate(4, 5.5, 8)
left_rotate(1, 132, 15)
left_rotate(2, 8, 18)
left_rotate(5, 5, 18)
left_rotate(4, 4, 17)
left_rotate(1, 70, 5)
right_rotate(3, 5, 8)
goto(90, 67)
fillcolor('pink')
end_fill()
left_rotate(1, 180, 5)
right_rotate(1, 63, 10)
left_rotate(4, 2, 12)
right_rotate(3, 3, 16)
width(3)
right_rotate(3, 6, 15)
right_rotate(4, 5, 13.5)
fill_color_patch(90, 80, c='#E6E6FA')
begin_fill()
set_start(90, 80, w=1, c='#E6E6FA')
left_rotate(1, 175, 10)
left_rotate(4, 10, 12)
left_rotate(4, 7, 15)
right_rotate(4, 5, 9)
left_rotate(1, 150, 15)
left_rotate(4, 7.5, 15)
left_rotate(2, 3, 15)
right_rotate(2, 2, 10)
left_rotate(2, 7, 12)
goto(90, 80)
fillcolor('#E6E6FA')
end_fill()
fill_color_patch(90, 85, c='#D6D2F6')
begin_fill()
set_start(90, 85, w=1, c='#D6D2F6')
left_rotate(1, 175, 10)
left_rotate(4, 10, 10)
left_rotate(4, 6, 15)
right_rotate(4, 5, 7)
left_rotate(1, 153, 15)
left_rotate(3, 9.5, 15)
left_rotate(2, 2, 15)
right_rotate(3, 0, 10)
goto(90, 85)
fillcolor('#D6D2F6')
end_fill()
set_start(90.00, 67.00, w=4, c='#9392B3')
setheading(327.67)
left_rotate(1, 180, 5)
right_rotate(1, 63, 10)
left_rotate(4, 2, 12)
right_rotate(3, 3, 16)
width(3)
right_rotate(3, 6, 15)
right_rotate(4, 5, 13.5)
def draw_cat():
set_start(34, 141, w=1, c='#C65B03')
draw_circle(5, '#C65B03', color2='')
set_start(33.5, 139, w=1, c='#ED9C22')
draw_circle(3, '#ED9C22', color2='')
fill_color_patch(-23, 90, c='#850009')
begin_fill()
set_start(-23, 90, w=2, c='#850009')
left_rotate(1, 80, 10)
right_rotate(6, 4, 14.2)
left_rotate(1, 105, 9)
left_rotate(2, 8, 8)
width(3)
left_rotate(11, 12, 10)
width(2)
left_rotate(2, 12, 12)
goto(-23, 90)
fillcolor('#B80705')
end_fill()
fill_color_patch(46, 110, c='#850009')
begin_fill()
set_start(46, 110, w=3, c='#850009')
right_rotate(1, 145, 9)
left_rotate(2, 16, 8)
width(2)
left_rotate(3, 22, 2)
left_rotate(3, 12, 9)
goto(46, 110)
fillcolor('#E50703')
end_fill()
fill_color_patch(-23, 90, c='#BE7728')
begin_fill()
set_start(-23, 90, w=2, c='#BE7728')
left_rotate(1, 80, 10)
right_rotate(6, 4, 14.2)
left_rotate(1, 105, 9)
left_rotate(2, 8, 8)
width(3)
left_rotate(1, 55, 10)
left_rotate(2, 5, 15)
left_rotate(3, 6.5, 16)
width(2)
left_rotate(1, 55, 10)
left_rotate(2, 10, 8)
goto(-23, 90)
fillcolor('#E4C127')
end_fill()
fill_color_patch(20, 98, c='#DC960D')
begin_fill()
set_start(20, 98, w=1, c='#DC960D')
left_rotate(1, 75, 5)
left_rotate(2, 12, 5)
left_rotate(3, 33, 4)
left_rotate(3, 35, 1)
right_rotate(3, 28, 2)
left_rotate(3, 35, 3)
right_rotate(3, 30, 2)
left_rotate(3, 45, 2)
left_rotate(1, 30, 2)
right_rotate(3, 25, 1)
left_rotate(3, 45, 2)
left_rotate(1, 30, 2)
goto(20, 98)
fillcolor('#DC960D')
end_fill()
fill_color_patch(22, 99, c='#839D76')
begin_fill()
set_start(22, 99, w=1, c='#839D76')
left_rotate(1, 25, 0)
left_rotate(3, 30, 4)
left_rotate(3, 30, 2)
left_rotate(3, 30, 4)
left_rotate(3, 30, 2)
fillcolor('#839D76')
end_fill()
begin_fill()
set_start(24, 99, w=1, c='#398640')
left_rotate(1, 25, 0)
left_rotate(3, 30, 2.5)
left_rotate(3, 30, 2)
left_rotate(3, 30, 2.5)
left_rotate(3, 30, 2)
fillcolor('#398640')
end_fill()
begin_fill()
set_start(25.5, 101, w=1, c='#0ADBC9')
left_rotate(1, 25, 0)
left_rotate(3, 30, 1.8)
left_rotate(3, 30, 1)
left_rotate(3, 30, 1.8)
left_rotate(3, 30, 1)
fillcolor('#0ADBC9')
end_fill()
def draw_head():
fill_color_patch(46, 83, c='#9392B3')
begin_fill()
set_start(46, 83, w=4, c='#9392B3')
left_rotate(1, 105, 10)
right_rotate(3, 8, 20)
right_rotate(3, 10, 22)
right_rotate(1, 13, 15)
left_rotate(3, 3, 9)
left_rotate(2, 12, 6)
left_rotate(1, 30, 5)
left_rotate(2, 15, 3)
right_rotate(1, 135, 8)
right_rotate(3, 8, 8)
left_rotate(1, 140, 8)
left_rotate(2, 10, 8)
right_rotate(1, 130, 8)
right_rotate(5, 7.5, 7.5)
left_rotate(1, 140, 5)
left_rotate(2, 8, 5)
right_rotate(1, 125, 5)
right_rotate(5, 8, 6)
goto(125, -130)
set_start(125, -130, w=4, c='#9392B3')
left_rotate(1, 78, 10)
right_rotate(3, 5, 18)
right_rotate(4, 6, 21)
right_rotate(5, 5, 18)
right_rotate(3, 7, 20)
left_rotate(1, 15, 10)
right_rotate(2, 5, 6)
right_rotate(4, 7, 6.5)
right_rotate(1, 130, 5)
left_rotate(3, 11, 4.5)
left_rotate(1, 140, 7)
right_rotate(3, 12, 6)
right_rotate(5, 5, 5)
right_rotate(1, 130, 5)
left_rotate(3, 5, 4)
left_rotate(3, 13, 3)
left_rotate(1, 120, 8)
right_rotate(5, 10, 6.5)
right_rotate(1, 95, 5)
left_rotate(3, 12, 5)
left_rotate(3, 10, 10)
right_rotate(3, 5, 12)
right_rotate(3, 2, 5)
right_rotate(3, 5, 12)
right_rotate(4, 5, 13)
left_rotate(3, 6, 6)
left_rotate(5, 13.5, 7)
right_rotate(1, 158, 8)
right_rotate(3, 7, 7)
right_rotate(5, 15, 5)
fillcolor('white')
end_fill()
if __name__ == '__main__':
title('Python顾木子吖(公众号)')
wide = 800
height = 600
screensize(wide, height, '#DC0058')
setup(wide+30, height+30, 50, 10)
shape(name='turtle')
time.sleep(2)
draw_ear()
draw_cat()
draw_head()
# draw_face()
# draw_mouth()
# draw_eye()
# draw_eyebrow()
# draw_nose()
# draw_cheek()
# draw_forehead()
# draw_foot()
# draw_body()
# draw_hand()
# draw_clothes()
# draw_jade()
set_start(1000, 1000, 2.5)
done()
2)效果展示
总结
2023祝大家大展宏兔,前途似锦,兔年吉祥!
好啦!今天的内容写到这里就结束了哈,记得三连关注一下哦~
老规矩源码基地见,资料都是免费拿滴,没拿到的不要急一个一个来哈,可能有时候不是很及
时,多多包涵哦~
????完整的免费源码领取处:找我吖!文末公众hao可自行领取,滴滴我也可!
????推荐往期文章——
项目1.0 玫瑰花(内含多份源码)
【Turtle玫瑰汇总】温柔且浪漫至极——“玫瑰的花期到了“
项目1.1 雪花(内含多份源码)
Turtle系列:下雪了,下雪了、最漂亮的雪景在这里....太美了
项目 2.1 樱花将灿,冬尽风暖
漫天樱花表白小程序:“樱花将灿,冬尽风暖“一樱花和你我都想念~(内含多份源码)
项目 2.2 源码合集(表白)
Turtle系列:小人发射爱心、文字表白、一箭穿心你想要的都在这个小程序哦~(超值)
项目2.3 魔法阵合集
【Turtle合集】火遍抖音的五款魔法阵终于被我找到了(初代萌王,童年的小樱回来了)
????文章汇总——
汇总合集 Python—2022 |已有文章汇总 | 持续更新,直接看这篇就够了
(更多内容+源码都在✨文章汇总哦!!欢迎阅读喜欢的文章????~)