#2024新年快乐,新年烟花,MATLAB烟花设计 #新年烟花

  前言:2024已经到来,祝所有的小盆友们新年快乐!!!!!

一.设置黑色背景图框

  首先,设置所需的图框并对图框进行标注尺寸 

 

 

如图所示 :

 

 

二.作出星星图  

  通过axes()函数作出坐标区并画出星星图样 

 

如图所示: 

 

 

三.作出月亮图 

 

  同理作出坐标区并绘制月亮 

 

 

如图所示: 

 

四.绘制烟花 

  这里我们一共绘制了七个烟花,其中包括对于烟花的坐标区间,烟花的升空和爆炸设计,以及对于烟花的尺寸标注颜色定义等。 

 

 

 

 

 

 

 

五.一些烟花的静止图 

  这里还不知道咋导出gif图所以就只有一些静止图(希望可以复制运行一下还是蛮好看嘞),以下是一些截屏的静止图。

如图: 

 

 

 

 

 

 

六.整个的烟花源码 

 

figure    %设置黑色背景图框
set(gcf,'Color',[0 0 0],'Position',[400 200 700 600])  %对图框的大小及背景颜色进行标注

%利用axes()函数创建坐标区
ax1=axes('Position',[0.01 0.6 0.95 0.4]);
%画出星星图
hold on 
for i=1:100
    plot(rand(1),rand(1),'p',...
        'MarkerFaceColor',[1 1 1],'MarkerEdgeColor',[1 1 1],'MarkerSize',randi(4,1)) %白色星星
end
axis off

%创建月亮的坐标区
ax2=axes('Position',[0.8 0.8 0.3 0.3]); 
%画出月亮
[r,theta]=meshgrid(0:0.01:1,linspace(0,2*pi,100));
[X,Y]=pol2cart(theta,r);  %极坐标转化为直角坐标系
Z=X.^2+Y.^2;
pcolor(X,Y,Z)
axis equal
shading interp
colormap gray %灰色渲染
axis off

%创建烟花坐标区
%绘制烟花一号
ax3=axes('Position',[0.05 0.05 0.9 0.9]);  %这里默认0.05,0.05为该图的中点坐标位置
c=[0.8 0.97 0.5]; % 颜色接近火焰
for i=1:100
    plot(0,i,'.','LineWidth',2,'MarkerFaceColor',c-[0 0 i/100/2.2],...
        'MarkerEdgeColor',[min(rand(1)*3,1),rand(1),rand(1)],'MarkerSize',6)
    axis([-100 100 0 200])
    axis equal
    axis off
    drawnow
end
%烟花升空炸裂
theta=sort(rand(1,60))*2*pi;
t=(0:0.01:2)'; % 时间
v0=15; % 初始速度
xx=v0*cos(theta).*t;
yy=(v0*sin(theta)+5).*t-1/2*10*t.^2+100;
h = animatedline('Marker','.','LineStyle','none','MarkerSize',0.1);
for i=1:length(xx)
    addpoints(h,xx(i,:),yy(i,:));
    set(h,'Color',[rand(1),rand(1),rand(1)])
    axis([-100 100 0 200])
    axis off
    drawnow
end
%烟花二号
ax4=axes('Position',[0.35 0.15 0.9 0.9]);
c=[0.8 0.97 0.5]; % 颜色接近火焰
for i=1:100
    plot(0,i,'.','LineWidth',2,'MarkerFaceColor',c-[0 0 i/100/2.2],...
        'MarkerEdgeColor',[min(rand(1)*3,1),rand(1),rand(1)],'MarkerSize',6)
    axis([-100 100 0 200])
    axis equal
    axis off
    drawnow
end

theta=sort(rand(1,60))*2*pi;
t=(0:0.01:2)'; % 时间
v0=15; % 初始速度
xx=v0*cos(theta).*t;
yy=(v0*sin(theta)+5).*t-1/2*10*t.^2+100;
h = animatedline('Marker','.','LineStyle','none','MarkerSize',0.1);
for i=1:length(xx)
    addpoints(h,xx(i,:),yy(i,:));
    set(h,'Color',[rand(1),rand(1),rand(1)])
    axis([-100 100 0 200])
    axis off
    drawnow
end
%烟花三号
ax5=axes('Position',[0.25 0.05 0.9 0.9]);
c=[0.8 0.97 0.5]; % 颜色接近火焰
for i=1:100
    plot(0,i,'.','LineWidth',2,'MarkerFaceColor',c-[0 0 i/100/2.2],...
        'MarkerEdgeColor',[min(rand(1)*3,1),rand(1),rand(1)],'MarkerSize',6)
    axis([-100 100 0 200])
    axis equal
    axis off
    drawnow
end

theta=sort(rand(1,60))*2*pi;
t=(0:0.01:2)'; % 时间
v0=15; % 初始速度
xx=v0*cos(theta).*t;
yy=(v0*sin(theta)+5).*t-1/2*10*t.^2+100;
h = animatedline('Marker','.','LineStyle','none','MarkerSize',0.1);
for i=1:length(xx)
    addpoints(h,xx(i,:),yy(i,:));
    set(h,'Color',[rand(1),rand(1),rand(1)])
    axis([-100 100 0 200])
    axis off
    drawnow
end
%烟花四号
ax6=axes('Position',[0.15 0.40 0.9 0.9]);
c=[0.8 0.97 0.5]; % 颜色接近火焰
for i=1:100
    plot(0,i,'.','LineWidth',2,'MarkerFaceColor',c-[0 0 i/100/2.2],...
        'MarkerEdgeColor',[min(rand(1)*3,1),rand(1),rand(1)],'MarkerSize',6)
    axis([-100 100 0 200])
    axis equal
    axis off
    drawnow
end

theta=sort(rand(1,60))*2*pi;
t=(0:0.01:2)'; % 时间
v0=15; % 初始速度
xx=v0*cos(theta).*t;
yy=(v0*sin(theta)+5).*t-1/2*10*t.^2+100;
h = animatedline('Marker','.','LineStyle','none','MarkerSize',0.1);
for i=1:length(xx)
    addpoints(h,xx(i,:),yy(i,:));
    set(h,'Color',[rand(1),rand(1),rand(1)])
    axis([-100 100 0 200])
    axis off
    drawnow
end
%烟花五号
ax7=axes('Position',[-0.20 0.15 0.9 0.9]);
c=[0.8 0.97 0.5]; % 颜色接近火焰
for i=1:100
    plot(0,i,'.','LineWidth',2,'MarkerFaceColor',c-[0 0 i/100/2.2],...
        'MarkerEdgeColor',[min(rand(1)*3,1),rand(1),rand(1)],'MarkerSize',6)
    axis([-100 100 0 200])
    axis equal
    axis off
    drawnow
end

theta=sort(rand(1,60))*2*pi;
t=(0:0.01:2)'; % 时间
v0=15; % 初始速度
xx=v0*cos(theta).*t;
yy=(v0*sin(theta)+5).*t-1/2*10*t.^2+100;
h = animatedline('Marker','.','LineStyle','none','MarkerSize',0.1);
for i=1:length(xx)
    addpoints(h,xx(i,:),yy(i,:));
    set(h,'Color',[rand(1),rand(1),rand(1)])
    axis([-100 100 0 200])
    axis off
    drawnow
end
%烟花六号
ax8=axes('Position',[-0.30 0.00 0.9 0.9]);
c=[0.8 0.97 0.5]; % 颜色接近火焰
for i=1:100
    plot(0,i,'.','LineWidth',2,'MarkerFaceColor',c-[0 0 i/100/2.2],...
        'MarkerEdgeColor',[min(rand(1)*3,1),rand(1),rand(1)],'MarkerSize',6)
    axis([-100 100 0 200])
    axis equal
    axis off
    drawnow
end

theta=sort(rand(1,60))*2*pi;
t=(0:0.01:2)'; % 时间
v0=15; % 初始速度
xx=v0*cos(theta).*t;
yy=(v0*sin(theta)+5).*t-1/2*10*t.^2+100;
h = animatedline('Marker','.','LineStyle','none','MarkerSize',0.1);
for i=1:length(xx)
    addpoints(h,xx(i,:),yy(i,:));
    set(h,'Color',[rand(1),rand(1),rand(1)])
    axis([-100 100 0 200])
    axis off
    drawnow
end
%烟花七号
ax9=axes('Position',[-0.10 0.35 0.9 0.9]);
c=[0.8 0.97 0.5]; % 颜色接近火焰
for i=1:100
    plot(0,i,'.','LineWidth',2,'MarkerFaceColor',c-[0 0 i/100/2.2],...
        'MarkerEdgeColor',[min(rand(1)*3,1),rand(1),rand(1)],'MarkerSize',6)
    axis([-100 100 0 200])
    axis equal
    axis off
    drawnow
end

theta=sort(rand(1,60))*2*pi;
t=(0:0.01:2)'; % 时间
v0=15; % 初始速度
xx=v0*cos(theta).*t;
yy=(v0*sin(theta)+5).*t-1/2*10*t.^2+100;
h = animatedline('Marker','.','LineStyle','none','MarkerSize',0.1);
for i=1:length(xx)
    addpoints(h,xx(i,:),yy(i,:));
    set(h,'Color',[rand(1),rand(1),rand(1)])
    axis([-100 100 0 200])
    axis off
    drawnow
end

最后祝大家2024新年快乐!!!!!! 

 

  • 25
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

袁满满满满

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值