您好,登錄后才能下訂單哦!
本篇內(nèi)容介紹了“Python和Matlab怎么實(shí)現(xiàn)櫻花的繪制”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
為什么選擇這個(gè)標(biāo)題,借鑒了一封情書里面的情長紙短,還吻你萬千。
錦短情長
都只謂人走茶涼,怎感覺錦短情長?
一提起眼淚汪汪,是明月人心所向?
function pingba hold on,axis equal axis(0.5+[-10,50,0,50]) set(gca,'xtick',[],'ytick',[],'xcolor','w','ycolor','w') set(gca,'color',[0.5020 0.5020 0.5020]) length_trunk=6; width_trunk=4; k1=0.9; k2=0.8; number_branch=15; alp=pi/10; length_branch=k1*length_trunk; width_branch=k2*width_trunk; trunk=[12,0;12,length_trunk]; plot(trunk(:,1),trunk(:,2),'color',[0 0 0],'Linewidth',width_trunk) begins=[trunk(2,:),pi/2,1]; grow=begins; plotdata=[0 0 0 0 0 0 0 0]; plotdata(1,:)=[]; for i=1:number_branch control=randi(25,[length(grow(:,1)),1])>=10; ag=grow(:,3); l=length(ag); parta=[length_branch.*k1.^grow(:,4).*cos(ag+ones(l,1)*alp),length_branch.*k1.^grow(:,4).*sin(ag+ones(l,1)*alp),ones(l,1)*alp,ones(l,1)]; partb=[length_branch.*k1.^grow(:,4).*cos(ag-ones(l,1)*alp),length_branch.*k1.^grow(:,4).*sin(ag-ones(l,1)*alp),-ones(l,1)*alp,ones(l,1)]; parta2=[0.8.*length_branch.*k1.^grow(:,4).*cos(ag),0.8.*length_branch.*k1.^grow(:,4).*sin(ag),zeros(l,1),ones(l,1)]; partb2=[0.8.*length_branch.*k1.^grow(:,4).*cos(ag),0.8.*length_branch.*k1.^grow(:,4).*sin(ag),zeros(l,1),ones(l,1)]; parta=control.*parta+(1-control).*parta2; partb=control.*partb+(1-control).*partb2; parta=parta+grow; partb=partb+grow; congress=[parta;partb]; grow=[grow;grow]; judge=[grow,congress]; judge=unique(judge,'rows'); grow=judge(:,5:end); plotdata=[plotdata;judge]; end for i=1:number_branch temp_w=width_branch*0.8^i; temp_branch=plotdata(plotdata(:,4)==i,:); plx=[temp_branch(:,1),temp_branch(:,5)]; ply=[temp_branch(:,2),temp_branch(:,6)]; plx=plx';ply=ply'; plot(plx,ply,'color',[0 0 0]+i*[0.3020 0.3020 0.3020]./number_branch,'Linewidth',temp_w) end bloom_pos=plotdata(plotdata(:,8)==number_branch+1,[5,6]); scatter(bloom_pos(:,1),bloom_pos(:,2),10,'CData',[0.8549 0.6824 0.6824]) bloom_pos=plotdata(plotdata(:,8)==number_branch,[5,6]); scatter(bloom_pos(:,1),bloom_pos(:,2),8,'CData',[0.7451 0.5961 0.5961].*0.97) end
import turtle as T import random import time #=======畫櫻花的軀干(60,t)=============== T.title('凋落的櫻花') def Tree(branch, t): time.sleep(0.0005) if branch > 3: if 8 <= branch <= 12: if random.randint(0, 2) == 0: t.color('snow') # 白 else: t.color('lightcoral') # 淡珊瑚色 t.pensize(branch / 3) elif branch < 8: if random.randint(0, 1) == 0: t.color('snow') else: t.color('lightcoral') # 淡珊瑚色 t.pensize(branch / 2) else: t.color('sienna') # 赭(zhě)色 t.pensize(branch / 10) # 6 t.forward(branch) a = 1.5 * random.random() t.right(20 * a) b = 1.5 * random.random() Tree(branch - 10 * b, t) t.left(40 * a) Tree(branch - 10 * b, t) t.right(20 * a) t.up() t.backward(branch) t.down() #=============掉落的花瓣=================== def Petal(m, t): for i in range(m): a = 200 - 400 * random.random() b = 10 - 20 * random.random() t.up() t.forward(b) t.left(90) t.forward(a) t.down() t.color('lightcoral') # 淡珊瑚色 t.circle(1) t.up() t.backward(a) t.right(90) t.backward(b) #=======繪圖區(qū)域============ t = T.Turtle() # 畫布大小 w = T.Screen() t.hideturtle() # 隱藏畫筆 t.getscreen().tracer(5, 0) w.screensize(bg='wheat') # wheat小麥 t.left(90) t.up() t.backward(150) t.down() t.color('sienna') #=====畫櫻花的軀干=========== Tree(60, t) # 掉落的花瓣 Petal(200, t) w.exitonclick()
“Python和Matlab怎么實(shí)現(xiàn)櫻花的繪制”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。