该程序使用的 函数都是matlab中基础的fill scatter plot等函数,但代码的理解需要对矩阵使用有一定熟练度,该程序所绘制的雪景会在一定范围内自行调整,每次运行都会有不一样的惊喜!!
效果展示:
完整代码:
function snowCover
MainFig=figure('units','pixels','position',[300 80 500 500],...
'Numbertitle','off','menubar','none','resize','off',...
'name','snow covered landscape');
axes('parent',MainFig,'position',[0 0 1 1],...
'XLim', [0 500],...
'YLim', [0 500],...
'NextPlot','add',...
'layer','bottom',...
'Visible','on',...
'Color',[0 59 129]./255,...
'XTick',[], ...
'YTick',[]);
hold on
%画雪地====================================================================
layerBEPos=[150;140;100;90];
layerColor=[146 210 245;101 183 231;0 101 181;0 59 129];
excursion=15;
interval=10;
xSep=25;
layerPos=zeros(size(layerBEPos,1),length(xSep:xSep:500));
layerPos(:,1)=layerBEPos(:,1);
for i=1:size(layerBEPos,1)
for j=xSep:xSep:500
listPos=round(j./xSep+1);
tempRandi=randi([-excursion,excursion]);
yPos=tempRandi+layerPos(i,listPos-1);
if i>1&&yPos>=layerPos(i-1,listPos)-5
yPos=layerPos(i-1,listPos)-interval;
end
yPos(yPos
关注
打赏