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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

為什么星星固定在左上角了?

<!DOCTYPE html>

<html>


<head>

<meta charset="UTF-8">

<title>星空</title>

<style type="text/css">

*{

margin: 0;

padding: 0;

}

body{

text-align: center;

}

</style>

</head>


<body>

<canvas id="canvas" >瀏覽器不支持的時(shí)候顯示</canvas>

<script type="text/javascript">

window.onload = function() {

var canvas = document.getElementById("canvas");

var context = canvas.getContext('2d');

canvas.width = 800;

canvas.height = 800;

context.fillStyle = '#000';

context.fillRect(0,0,canvas.width,canvas.height);

for(var i=0;i<200;i++) {

var r = Math.random()*10+10; // 10~20

var x = Math.random()*canvas.width;

var y = Math.random()*canvas.height;

var a = Math.random()*360;

drawStart(context,r/2.0,r,x,y,a);

}

}

function drawStart(cxt,x,y,R,rot) {

// 繪制出在(x,y),大小為R,旋轉(zhuǎn)角度為rot的五角星

// 位移? translate(x, y)

// 旋轉(zhuǎn)? rotate(deg);

// 縮放? scale(sx,sy)

cxt.save();

cxt.translate(x, y);

cxt.rotate(rot/180*Math.PI);

startPath(cxt);

cxt.fillStyle = '#fb3';

cxt.strokeStyle = '#fd5';

cxt.lineWidth = 3;

cxt.lineJoin = 'round';

cxt.fill();

cxt.stroke();

cxt.restore();

}

// 標(biāo)準(zhǔn)五角星的路徑

function startPath(cxt) {

cxt.beginPath();

for(var i=0;i<5;i++) {

cxt.lineTo(Math.cos((18+i*72)/180*Math.PI)*20,

-Math.sin((18+i*72)/180*Math.PI)*20);

cxt.lineTo(Math.cos((54+i*72)/180*Math.PI)*0.5*20,

-Math.sin((54+i*72)/180*Math.PI)*0.5*20);

}

cxt.closePath();

}

</script>

</body>


</html>


正在回答

1 回答

你函數(shù)參數(shù)值沒對(duì)應(yīng)起來? 具體就是以下兩行代碼

drawStart(context,r/2.0,r,x,y,a);
function?drawStart(cxt,x,y,R,rot)?{

沒有一一對(duì)應(yīng)啊, 你把r/2.0當(dāng)成x傳給了 drawStart?


不知道能不能理解

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

為什么星星固定在左上角了?

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)