MATLAB绘制美丽玫瑰代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

functionplot_rosedraw_main(450,90);functiondraw_main(x,y)%粉红色玫瑰arcdata{1}=[65-60150350866-54300470865-56302301064-5730049017];ellipsedata{1}=[73-30250450274059-30100290274065-401402702030];arcdata{2}=[001503501218280470120230230160380240282818033022-2231046025];ellipsedata{2}=[-1230120300304010282504233042-4102903933040];ellipsedata{3}=[120503601525];ellipsedata{4}=[-701003601420];rose_e{2}=[x+16y+322353552635x-15y+321903103035x+0y+351903504350];rose_e{1}=[x+80y-482203502250x+50y-481903202250x+65y-281803603650];rose_e{3}=[x+120y-62003401725x+120y+71603801727];rose_e{4}=[x-70y+151403901720x-75y-102053401030x-60y-10195340530];arcdata{3}=[0821903506];ss={'m','r','b','y'};s0={'k','k','g'};figure('menubar','none','numbertitle','off','name','美丽玫瑰');%figure('numbertitle','off','name','rose');holdonforj=1:length(ellipsedata)fori=1:size(ellipsedata{j},1)rectangle('Position',[x+ellipsedata{j}(i,1)-ellipsedata{j}(i,5),y+ellipsedata{j}(i,2)-ellipsedata{j}(i,6),2*ellipsedata{j}(i,5),2*ellipsedata{j}(i,6)],'Curvature',[1,1],'FaceColor',ss{j})endifj4fori=1:size(arcdata{j},1)draw_arc(x+arcdata{j}(i,1),y+arcdata{j}(i,2),arcdata{j}(i,3),arcdata{j}(i,4),arcdata{j}(i,5),s0{j});endendfori=1:size(rose_e{j},1)plot_rose_e(rose_e{j},j);endendforj=1:3zhuzhi=[x-98,y+100+j,255,371,100,80x-20,y+30+j,260,358,140,140x+224,y+20+j,180,218,160,140];draw_branch(zhuzhi);endce_branch=[x+70,y+34,180,233,140,140;x,y+40,205,255,100,120;x+135,y-30,209,249,72,120;x,y+20,263,301,100,120;x+85,y-10,278,305,100,120;x+100,y-62,282,308,90,120;x-50,y-10,277,314,30,120;x+70,y+80,222,266,52,120;x-60,y-45,229,266,52,120;x+79,y-45,229,266,52,120;x+84,y,224,273,52,120;x+110,y+40,240,282,100,120];draw_branch(ce_branch);t_leaf=[x+168,y+282,10,20,-40;x+160,y+252,8,16,260;x+145,y+270,8,16,-15;x+156,y+224,10,20,-45;x+150,y+200,8,16,270;x+135,y+220,8,16,-10;x+146,y+144,8,16,-80;x+130,y+130,6,12,235;x+125,y+154,7,14,-10;x+78,y+98,6,12,-90;x+60,y+90,5,10,180;x+70,y+109,5,10,-45;x-125,y+270,12,24,60;x-95,y+270,10,20,10;x-110,y+245,10,20,90;x-105,y+220,10,20,45;x-100,y+190,8,16,135;x-75,y+210,8,16,-45;x+65,y+190,10,20,-45;x+40,y+185,8,16,0;x+55,y+165,8,16,90];forj=1:size(t_leaf,1)draw_elli(t_leaf(j,1),t_leaf(j,2),t_leaf(j,3),t_leaf(j,4),t_leaf(j,5));endaxisijaxisoffset(gcf,'color','k');daspect([1,1,1])%画旋转椭圆functiondraw_elli(x0,y0,a,b,theta)theta=-theta;t=0:0.01:2*pi;x=a*cos(t);y=b*sin(t);xy=zeros(2,length(t));fori=1:length(t)xy(:,i)=expm([0,-pi/180*theta;pi/180*theta,0])*[x(i);y(i)];endplot(x0+xy(1,:),480-y0+xy(2,:),'g');%画弧线functiondraw_arc(x0,y0,st_a,en_a,r,c_c)t=(pi/180*st_a:0.01:pi/180*en_a)-pi;x=x0+r*cos(t);y=y0+r*sin(t);plot(x,y,c_c);%花萼functionplot_rose_e(matr,ch)x=[];y=[];n=size(matr,1);fori=1:size(matr,1)t=(matr(i,3):matr(i,4))*pi/180-pi;x1=matr(i,1)+matr(i,5)*cos(t);y1=matr(i,2)+matr(i,6)*sin(t);ifi3x1=2*matr(i,1)-x1;endx1=fliplr(x1);y1=fliplr(y1);ifn3&&i2x1=fliplr(x1);y1=fliplr(y1);endifch==4&&i==2x1=fliplr(x1);y1=fliplr(y1);endx=[x,x1];y=[y,y1];endfill(x,y,'g');%画树枝functiondraw_branch(zhuzhi)fork=1:size(zhuzhi,1)t=(zhuzhi(k,3):zhuzhi(k,4))*pi/180-pi;x1=zhuzhi(k,1)+zhuzhi(k,5)*cos(t);y1=zhuzhi(k,2)+zhuzhi(k,6)*sin(t);x1=2*zhuzhi(k,1)-x1;plot(x1,y1,'g','linewidth',2);endtitle('玫瑰');

1 / 4
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功