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

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

為何黑色背景顯示不出來

<!DOCTYPE html>

<html>

<head>

<title>星空</title>

</head>

<body>

<canvas id = "canvas" style="border:1px solid #ccc;margin:50px auto ;display:block">

該瀏覽器不支持canvas,請使用其他瀏覽器。

</canvas>

<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="black";

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

// context.strokeRect=(0,0,canvas.width,canvas.height);

// context.stroke();

drawStar(context,300,100,400,400,30);


}

function drawStar(cxt,R,r,x,y,rot){

cxt.beginPath();

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

cxt.lineTo(Math.cos((18+72*i-rot)/180*Math.PI)*R+x,-Math.sin((18+72*i-rot)/180*Math.PI)*R+y);

cxt.lineTo(Math.cos((54+72*i - rot)/180*Math.PI)*r+x,-Math.sin((54+72*i- rot)/180*Math.PI)*r+y);

? ? }

cxt.closePath();

cxt.fillStyle = '#FB3';

cxt.strokeStyle = '#FD5';

cxt.lineJoin = 'round';

cxt.lineWidth = 3;

cxt.fill();

cxt.stroke();

}

</script>

</body>

</html>

正在回答

1 回答

寫錯了?。。。∈沁@樣子寫的 context.fillRect(0,0,canvas.width,canvas.height);

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

舉報

0/150
提交
取消

為何黑色背景顯示不出來

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

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

幫助反饋 APP下載

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

公眾號

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