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

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

為什么我的五角星沒有畫出來,全黑了呢?

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>

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


</canvas>

<script type="text/javascript">

var searchLight = {x:400,y:300,radius:100,vx:Math.random()*5+10,vy:Math.random()*5+10};

var isIncrease ?= true;

window.onload = function(){

canvas.width = 800;

canvas.height = 600;

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


setInterval(

function(){

draw(context);

update();

},

40

)

}

function draw(cxt){

var canvas = cxt.canvas;

cxt.clearRect(0,0,canvas.width,canvas.height);


cxt.save();

cxt.beginPath();

cxt.fillStyle = "black";

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


cxt.save();

cxt.translate(searchLight.x,searchLight.y);

cxt.scale(searchLight.radius,searchLight.radius);

starPath(cxt);

cxt.fillStyle = "#fff";

cxt.fill();

cxt.restore();

cxt.clip();


cxt.font = "bold 150px Arial";

cxt.textAlign = "center";

cxt.textBaseline = "middle";

cxt.fillStyle = "#058";

cxt.fillText("CANVAS",canvas.width/2,canvas.height/4);

cxt.fillText("CANVAS",canvas.width/2,canvas.height/2);

cxt.fillText("CANVAS",canvas.width/2,canvas.height*3/4);

cxt.restore();

}

function update(){

if(searchLight.radius>700){

isIncrease = false

}else if(searchLight.radius<150){

isIncrease = true;

}

if (isIncrease) {

searchLight += 5;

}else{

searchLight -+ 5;

}

}

//繪制星星

function starPath(cxt){

cxt.beginPath();

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


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

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

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

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

}

cxt.closePath();

}

</script>

</body>

</html>



正在回答

3 回答

我發(fā)現(xiàn)你一開始沒有定義canvas,然后就直接給canvas設置寬高了

0 回復 有任何疑惑可以回復我~
function?update()?{

??if?(searchLight.radius?>?700)?{
????isIncrease?=?false
??}?else?if?(searchLight.radius?<?150)?{
????isIncrease?=?true;
??}
??
??/*?修改以下部分即可?*/
??///////////////////////
??if?(isIncrease)?{
????searchLight.radius?+=?5;
??}?else?{
????searchLight.radius?-=?5;
??}
??///////////////////////
}


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

舉報

0/150
提交
取消

為什么我的五角星沒有畫出來,全黑了呢?

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

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

幫助反饋 APP下載

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

公眾號

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