MATLAB | 七夕节快到了,还不给朋友安排上这个咕呱小青蛙?
Posted slandarer
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MATLAB | 七夕节快到了,还不给朋友安排上这个咕呱小青蛙?相关的知识,希望对你有一定的参考价值。
咕呱,咕呱,咕呱
咕呱,咕呱,咕呱
咕呱,咕呱,咕呱
七夕节到了还不快给你的朋友安排上这只咕呱小青蛙?
基础代码
function gugua
ax=gca;
ax.DataAspectRatio=[1 1 1];
ax.XLim=[-5 5];
ax.YLim=[-5 5];
ax.XColor='none';
ax.YColor='none';
ax.Color=[115,173,194]./255;
hold on
% hold(ax,'on')
% =========================================================================
% 绘制荷叶
[X,Y]=getEllipse([0.14,-1.5],3.6,1.8,0,200);
fill(X,Y,[166,211,177]./255,'EdgeColor',[41,47,50]./255,'LineWidth',4,'FaceAlpha',1)
fill([1.45,1.5,2.75],[-3.4,-2.4,-2.95],[115,173,194]./255,'EdgeColor','none')
plot([1.4,1.5,2.6],[-3.2,-2.4,-2.8],'Color',[41,47,50]./255,'LineWidth',4)
plot([-1.1,-0.8],[-3.2,-2.6],'Color',[51,57,50]./255,'LineWidth',2)
plot([-.6,-0.5],[-3.2,-2.9],'Color',[51,57,50]./255,'LineWidth',2)
plot([-3.3,-2.8],[-1.7,-1.63],'Color',[51,57,50]./255,'LineWidth',2)
% 绘制小草
[X,Y]=getEllipse([0,0],.62,.5,0,200);
Y=Y-.2;
X(Y<0)=[];Y(Y<0)=[];
X=[X,X(end:-1:1)];
Y=[Y,-Y(end:-1:1)];
[X1,Y1]=rotateData(X,Y,pi/8);X1=X1+.85;Y1=Y1+3.2;
[X2,Y2]=rotateData(X,Y,-pi/8);X2=X2-.15;Y2=Y2+3.2;
plot([.3,.33],[2.5,3],'Color',[41,47,50]./255,'LineWidth',4)
fill(X1,Y1,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
fill(X2,Y2,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
% 绘制腿部
[X,Y]=getEllipse([1.65,-1.5],.5,.2,0,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([1.55,-1.8],.4,.15,-pi/5,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([1.28,-1.8],.4,.2,-pi/2.5,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([1.8,-.6],1.3,.8,pi/6,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
%
[X,Y]=getEllipse([-1.55,-1.3],.5,.2,0,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([-1.48,-1.6],.4,.15,pi/5,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([-1.18,-1.7],.4,.2,pi/2.5,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([-1.6,-.45],1.3,.8,-pi/6,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
% 绘制身体和肚子
[X,Y]=getEllipse([0.27,0.4],2.25,2.18,0,200);
fill(X,Y,[185,215,108]./255,'EdgeColor',[41,47,50]./255,'LineWidth',4,'FaceAlpha',1)
[X,Y]=getEllipse([0.18,-.48],1.05,.75,-pi/15,200);
fill(X,Y,[253,241,155]./255,'EdgeColor',[41,47,50]./255,'LineWidth',1.8,'FaceAlpha',1)
% 绘制眼睛
[X,Y]=getEllipse([-1.39,2.1],.88,.81,pi/7,200);
fill(X,Y,[253,241,155]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([1.9,1.98],.89,.81,-pi/7,200);
fill(X,Y,[253,241,155]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([-1.28,2.1],.28,.28,0,200);
fill(X,Y,[41,47,50]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
[X,Y]=getEllipse([1.82,2.0],.28,.28,0,200);
fill(X,Y,[41,47,50]./255,'EdgeColor',[41,47,50]./255,'LineWidth',2,'FaceAlpha',1)
X=0:.01:pi;Y=-sin(X);
X=X./3.9-.2;
Y=Y./6+1.65;
plot(X,Y,'Color',[41,47,50]./255,'LineWidth',2)
% =========================================================================
% 椭圆数据点生成函数
function [X,Y]=getEllipse(Mu,XR,YR,theta,pntNum)
% Mu | 中心点
% XR,YR | 旋转前X,Y半轴长度
% theta | 旋转角度
% pntNum | 生成数据点个数
tList=linspace(0,2*pi,pntNum);
X=cos(tList).*XR;
Y=sin(tList).*YR;
rotateMat=[cos(theta),-sin(theta);sin(theta),cos(theta)];
XY=rotateMat*[X;Y]+Mu(:);
X=XY(1,:);Y=XY(2,:);
end
% 数据旋转角度
function [X,Y]=rotateData(X,Y,theta)
rotateMat=[cos(theta),-sin(theta);sin(theta),cos(theta)以上是关于MATLAB | 七夕节快到了,还不给朋友安排上这个咕呱小青蛙?的主要内容,如果未能解决你的问题,请参考以下文章
七夕节快到了,教你用MATLAB绘制blingbling的大钻石
七夕节快到了,教你用MATLAB绘制blingbling的大钻石
爬虫七夕快到了,想好和女朋友看什么片了吗?来一起用 Python 爬取豆瓣电影分类排行榜