第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

為什么一個星星都不能顯示,去掉for循環(huán)能顯示一個星星

<!DOCTYPE html>
<html>
<head>
?? ?<meta charset="UTF-8">
?? ?<title>一片星空</title>
?? ?<style type="text/css">
?? ??? ?body{background: #012;}
?? ?</style>
?? ?<script type="text/javascript">
?? ??? ?window.onload=function()
?? ??? ?{
?? ??? ??? ?var canvas=document.getElementById("canvas");
?? ??? ??? ?canvas.width=800;
?? ??? ??? ?canvas.height=800;

?? ??? ??? ?var context=canvas.getContext("2d");
?? ??? ??? ?
?? ??? ??? ?/*context.fillStyle="#012";
?? ??? ??? ?context.fillRect(0,0,convas.width,convas.height);*/
?? ??? ??? ?for(var i=0;i<200;i++)
?? ??? ??? ?{
?? ??? ??? ??? ?var r=Math.random()*10+10;
?? ??? ??? ??? ?var x=Math.random()*convas.width;
?? ??? ??? ??? ?var y=Math.random()*convas.height;
?? ??? ??? ??? ?var a=Math.random()*360;
?? ??? ??? ??? ?drawstar(context,r,r/2,x,y,a);
?? ??? ??? ?}
?? ??? ??? ?//drawstar(context,10,5,100,100,30);
?? ??? ?}
?? ??? ?function drawstar(cxt,oR,iR,x,y,rot)
?? ??? ?{
?? ??? ??? ?cxt.beginPath();
?? ??? ??? ?for(var i=0;i<5;i++)
?? ??? ??? ?{
?? ??? ??? ??? ?cxt.lineTo(Math.cos((18+i*72-rot)/180*Math.PI)*outerR+x,-Math.sin((18+i*72-rot)/180*Math.PI)*oR+y);
?? ??? ??? ??? ?cxt.lineTo(Math.cos((54+i*72-rot)/180*Math.PI)*innerR+x,-Math.sin((54+i*72-rot)/180*Math.PI)*iR+y);
?? ??? ??? ?}
?? ??? ??? ?cxt.lineWidth=1;
?? ??? ??? ?cxt.strokeStyle="#fd3";
?? ??? ??? ?cxt.fillStyle="#fd5";
?? ??? ??? ?cxt.lineJoin="round";
?? ??? ??? ?cxt.fill();
?? ??? ??? ?cxt.stroke(); //先填充后描邊
?? ??? ?}
?? ?</script>
</head>
<body>
?? ?<canvas id="canvas" style="border:1px solid #aaa;display:block;"></canvas>
</body>
</html>

正在回答

1 回答

把其中一個i循環(huán)的i變成j就可以了吧

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

舉報

0/150
提交
取消

為什么一個星星都不能顯示,去掉for循環(huán)能顯示一個星星

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

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號