Matlab怎么实现动态表白图的绘制
这篇文章主要介绍了Matlab怎么实现动态表白图的绘制的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇Matlab怎么实现动态表白图的绘制文章都会有所收获,下面我们一起来看看吧。
提前祝女朋友节日快乐
1 展现
这里没上传视频图,放最后一张成品:
2 代码
漂亮的颜色随你挑:
clearclctic%%构造体积方程和坐标轴[X,Y,Z]=meshgrid(linspace(-3,3,101));%%3D心型图方程F=-X.^2.*Z.^3-(9/80).*Y.^2.*Z.^3+(X.^2+(9/4).*Y.^2+Z.^2-1).^3;%%展开画布hFigure=figure;sz=get(hFigure,'Position');set(hFigure,'Position',[sz(1)-0.15*sz(3)sz(2)1.3*sz(3)sz(4)]);%设置画布大小set(hFigure,'color','w','menu','none')%隐藏菜单,颜色做白hAxes=axes('Parent',hFigure,...?'DataAspectRatio',[111],...???'XLim',[30120],'YLim',[3565],'ZLim',[3075]);view([-3930]);%视角axisoff%关闭坐标轴%hiddenon%%制作出动态的隐形效果p=patch(isosurface(F,0));set(p,'FaceColor','none','EdgeColor','none');%心形线和面隐藏alpha(0);%使其为0透明度以便显示文字text(45,50,60,'WLZ','fontweight','bold','fontsize',25,'color','m');%显示出文字pause(2)holdon%%描出Y-Z平面的心形轮廓foriX=35:1:67plane=reshape(F(:,iX,:),101,101);cData=contourc(plane,[00]);xData=iX.*ones(1,cData(2,1));plot3(hAxes,xData,cData(2,2:end),cData(1,2:end),'r');pause(0.1),drawnowend%%描出X-Z平面的心形轮廓foriY=41:2:61plane=reshape(F(iY,:,:),101,101);cData=contourc(plane,[00]);yData=iY.*ones(1,cData(2,1));plot3(hAxes,cData(2,2:end),yData,cData(1,2:end),'r');pause(.5),drawnowend%%描出X-Y平面的心形轮廓foriZ=36:1:71plane=F(:,:,iZ);cData=contourc(plane,[00]);startIndex=1;ifsize(cData,2)>(cData(2,1)+1)startIndex=cData(2,1)+2;zData=iZ.*ones(1,cData(2,1));plot3(hAxes,cData(1,2:(startIndex-1)),...?????cData(2,2:(startIndex-1)),zData,'r');endzData=iZ.*ones(1,cData(2,startIndex));plot3(hAxes,cData(1,(startIndex+1):end),...??????cData(2,(startIndex+1):end),zData,'r');pause(.1),drawnowend%%给三维心着色补光alpha(1)%恢复透明度set(p,'facecolor','m','edgecolor','none');camlight%补光lightinggouraudpause(.2)%做线line([2080],[5050],[52.52.5],'color','r')line([5050],[2080],[52.552.5],'color','r')line([5050],[5050],[3080],'color','r')pause(0.5)%文字部分;text(0,50,107,'好好疼你,陪你长大\heartsuit','fontweight','bold','fontsize',25,'color','r');pause(2)text(7,100,70,['WLZ\heartsuit'],'fontWeight','bold','FontAngle','italic','FontName','Trebuchet?MS','fontsize',45,'Color','c');pause(.5)text(80,50,43,'YOU','fontWeight','bold','FontAngle','italic','FontName','Trebuchet?MS','fontsize',60,'Color','k');pause(.2)text(75,5,40,'超级爱你\heartsuit','fontWeight','bold','FontAngle','italic','FontName','Trebuchet?MS','fontsize',20,'Color','g');pause(.2)text(120,0,20,'xys\heartsuit','fontWeight','bold','FontAngle','italic','FontName','Trebuchet?MS','fontsize',10,'Color','r');pause(.2)uicontrol(hFigure,'Style','Edit','Units','normalized','Position',[0,0.8,1,0.12],...'Backgroundcolor','[0,1,1]','String','520快乐','Fontsize',40,'Foregroundcolor','[1,0,1]');pause(.5)uicontrol(hFigure,'Style','Edit','Units','normalized','Position',[0,0.8,1,0.12],...'Backgroundcolor','[0.3,0.75,0.93]','String','520快乐','Fontsize',40,'Foregroundcolor','[1,0,1]');pause(.5)uicontrol(hFigure,'Style','Edit','Units','normalized','Position',[0,0.8,1,0.12],...'Backgroundcolor','[1,0.5,0]','String','520快乐','Fontsize',40,'Foregroundcolor','[1,0,1]');pause(.5)uicontrol(hFigure,'Style','Edit','Units','normalized','Position',[0,0.8,1,0.12],...'Backgroundcolor','[1,1,1]','String','520快乐','Fontsize',40,'Foregroundcolor','[1,1,1]');pause(.5)uicontrol(hFigure,'Style','Edit','Units','normalized','Position',[0,0.8,1,0.12],...'Backgroundcolor','[1,1,0]','String','520快乐','Fontsize',40,'Foregroundcolor','[1,1,1]');toc
关于“Matlab怎么实现动态表白图的绘制”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“Matlab怎么实现动态表白图的绘制”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注恰卡编程网行业资讯频道。