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

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

正在回答

2 回答

<!doctype?html>
<html?lang="zh-CN">
<head>
????<meta?charset="UTF-8">
????<meta?name="viewport"
?content="width=device-width,?user-scalable=no,?initial-scale=1.0,?maximum-scale=1.0,?minimum-scale=1.0">
????<meta?http-equiv="X-UA-Compatible"?content="ie=edge">
????<title>七巧板</title>
????<style?type="text/css">
????????#canvas?{
????????????border:?1px?solid?#ccc;
????????????display:?block;
????????????margin:?auto;
????????}
????</style>
</head>
<body>
<canvas?id="canvas"?width="400"?height="400"></canvas>

<script?type="text/javascript">
????var?tangram?=?[
????????{p:?[{x:?0,?y:?0},?{x:?400,?y:?0},?{x:?200,?y:?200}],?color:?"#ff0f09"},
????????{p:?[{x:?0,?y:?0},?{x:?0,?y:?400},?{x:?200,?y:?200}],?color:?"#feff0a"},
????????{p:?[{x:?0,?y:?400},?{x:?200,?y:?400},?{x:?100,?y:?300}],?color:?"#ff09f7"},
????????{p:?[{x:?100,?y:?300},?{x:?200,?y:?400},?{x:?300,?y:?300},{x:?200,?y:?200}],?color:?"#ffdc52"},
????????{p:?[{x:200,y:400},?{x:400,y:400},?{x:400,y:200}],?color:?"#0608ff"},
????????{p:?[{x:200,y:200},?{x:300,y:300},?{x:300,y:100}],?color:?"#30ff10"},
????????{p:?[{x:300,y:300},?{x:300,y:100},?{x:400,y:0},?{x:400,y:200}],?color:?"#ffa41a"},
????];

????var?canvas?=?document.getElementById("canvas");?//?獲取canvas
?var?context?=?canvas.getContext("2d");??//?獲取2d繪圖環(huán)境

?for?(var?i?=?0;?i?<?tangram.length;?i++)?{
????????draw(tangram[i],?context);
????}

????function?draw(piece,?context)?{
????????context.beginPath();

????????context.closePath();

????????context.moveTo(piece.p[0].x,?piece.p[0].y);

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

????????context.fillStyle?=?piece.color;
????????context.fill();
????}
</script>
</body>
</html>


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

照著老師那個(gè)坐標(biāo)圖看,初始點(diǎn)(x,y),每個(gè)圓占用 2*(r+1)的寬高的正方形,現(xiàn)在求從左往右數(shù)第j個(gè),從上往下數(shù)第i個(gè)圓的圓心:

customX = 2*(r+1)*j + (r+1);// j*每個(gè)圓占用的寬度 + 每個(gè)圓占用寬度/2

customY = 2*(r+1)*i + (r+1);//同理可證!

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

舉報(bào)

0/150
提交
取消

不明白X軸Y軸的 數(shù)值怎么得來的 算的那么準(zhǔn)

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

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

幫助反饋 APP下載

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

公眾號(hào)

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