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

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

怎么出不來,幫忙看看

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>

<canvas id="canvas" width="500" height="500" style="border:1px solid #999;margin:0 auto;display:block">

當(dāng)前瀏覽器不支持canvas</canvas>


<script type="text/javascript">

window.onload=function(){

var canvas=document.getElementById('canvas')

var cantext=canvas.getContext('2d')


var tangram=[

{p:[{x:0,y:0},{x:250,y:250},{x:0,y:500}],color:"red"},

{p:[{x:0,y:0},{x:250,y:250},{x:500,y:0}],color:"green"},

{p:[{x:250,y:250},{x:375,y:125},{x:375,y:375}],color:"#fof"},

{p:[{x:500,y:0},{x:375,y:125},{x:375,y:375},{x:500,y:250}],color:"#0ff"},

{p:[{x:250,y:250},{x:375,y:125},{x:375,y:375},{x:125,y:375}],color:"#888"},

{p:[{x:125,y:370},{x:0,y:500},{x:250,y:500}],color:"#00f"},

{p:[{x:250,y:500},{x:500,y:500},{x:500,y:250}],color:"#00f"}

]

for(var i=0;i<tangram.length;i++){

draw(tangram[i],cantext)

}

function draw(piece,cxt){

cxt.beginPath()

cxt.moveTo(piece.p[0].x,piece.p[0].y)//獲取到tangram[i]的第p[0]個的第一個元素的x與y

for(var i=1;i<piece.length;i++){

cxt.lineTo(piece.p[i].x,piece.p[i].y)

}

cxt.closePath()

cxt.fillStyle=piece.color

cxt.fill()

cxt.strokeStyle="black"

cxt.lineWidth=3

cxt.stroke()

}

}

</script>

</body>

</html>


正在回答

1 回答

for(var?i=1;i<piece.p.length;i++){
????cxt.lineTo(piece.p[i].x,piece.p[i].y)
}

注意for循環(huán)里面是?piece.p.length;

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

舉報(bào)

0/150
提交
取消

怎么出不來,幫忙看看

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

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

幫助反饋 APP下載

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

公眾號

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