課程
/前端開發(fā)
/Html5
/Canvas繪圖詳解
drawStar()函數(shù)中 為什么設(shè)置fillStyle沒效果,設(shè)置strokeStyle的顏色時(shí)表現(xiàn)為填充五角星?
2016-07-13
源自:Canvas繪圖詳解 4-3
正在回答
?function drawStar(cxt,r,R,x,y,rot){??cxt.beginPath();????for(var i=0;i<5; i++){??cxt.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*R+x,??????-Math.sin((18+i*72-rot)/180*Math.PI)*R+y);???????cxt.lineTo(Math.cos((54+i*72-rot)/180*Math.PI)*r+x,???-Math.sin((54+i*72-rot)/180*Math.PI)*r+y);?? }?? cxt.closePath();?? ?? cxt.strokeStyle="#fd5";?? cxt.lineWidth=3;?? cxt.fillStyle="#fd3";?? cxt.lineJoin="bevel";?? cxt.fill();?? cxt.stroke();???}
qq_咫尺天涯_11 提問者
舉報(bào)
Canvas系列教程第二課,詳解Canvas各接口,讓同學(xué)徹底掌握Canvas繪圖
1 回答為什么沒有效果
3 回答我的點(diǎn)擊效果沒有反應(yīng)
4 回答星星閃效果
3 回答canvas的復(fù)制效果
2 回答最后如果用copy是什么效果?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購(gòu)課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-07-13
?function drawStar(cxt,r,R,x,y,rot){
??cxt.beginPath();
????for(var i=0;i<5; i++){
??cxt.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*R+x,
??????-Math.sin((18+i*72-rot)/180*Math.PI)*R+y);?????
??cxt.lineTo(Math.cos((54+i*72-rot)/180*Math.PI)*r+x,
???-Math.sin((54+i*72-rot)/180*Math.PI)*r+y);
?? }
?? cxt.closePath();
??
?? cxt.strokeStyle="#fd5";
?? cxt.lineWidth=3;
?? cxt.fillStyle="#fd3";
?? cxt.lineJoin="bevel";
?? cxt.fill();
?? cxt.stroke();
?
??}