亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

關于星星重疊問題

var?ss=new?Array();
for(var?p=0;p<50;p++){
????var?r=Math.random()*10+10;
????var?x=Math.random()*can.width;
????var?y=Math.random()*can.height;
????var?rott=Math.random()*360;
????ss.push([r,x,y]);

????if?(Math.sqrt(Math.pow(ss[0][1]-x,2)+Math.pow(ss[0][2]-y,2))>ss[0][0]+r){
????????kk(tex,r,r/2,x,y,rott);
????}
}

function?kk(tex,R,r,x,y,rot)?{
????tex.lineWidth=10;
????tex.beginPath();
????for(var?i=0;i<5;i++){
????????tex.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*R+x,-Math.sin((18+i*72-rot)/180*Math.PI)*R+y);
????????tex.lineTo(Math.cos((54+i*72-rot)/180*Math.PI)*r+x,-Math.sin((54+i*72-rot)/180*Math.PI)*r+y);
????}
????tex.closePath();
????tex.fillStyle='#fb3';
????tex.strokeStyle='#fb5';
????tex.lineWidth=10;
????tex.lineJoin='round';
????tex.fill();
????tex.stroke();
}


正在回答

1 回答

這樣不行吧??

if?(Math.sqrt(Math.pow(ss[0][1]-x,2)+Math.pow(ss[0][2]-y,2))>ss[0][0]+r){
????????kk(tex,r,r/2,x,y,rott);
????}
????不是應該與前面生成的所有坐標都進行比較嗎?你這樣貌似只比較了第一個生成的坐標與當前坐標的距離大于直徑


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Canvas繪圖詳解
  • 參與學習       73010    人
  • 解答問題       441    個

Canvas系列教程第二課,詳解Canvas各接口,讓同學徹底掌握Canvas繪圖

進入課程

關于星星重疊問題

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號