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

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

兩個(gè)html文件分別放一個(gè)canvas,用同一個(gè)js文件,第二個(gè)html文件的canvas畫不出畫是咋回事?

兩個(gè)html文件分別放一個(gè)canvas,用同一個(gè)js文件,第二個(gè)html文件的canvas畫不出畫是咋回事?

var canvas = document.getElementById('myCanvas');

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

var pieces = [

{p:[{x:0, y:0}, {x:400, y:400}, {x:0, y:800}], color:'#FF0000'},

{p:[{x:0, y:0}, {x:400, y:400}, {x:800, y:0}], color:'#FFE32C'},

{p:[{x:0, y:800}, {x:200, y:600}, {x:400, y:800}], color:'#21D4FD'},

{p:[{x:400, y:800}, {x:800, y:400}, {x:800, y:800}], color:'#FAACA8'},

{p:[{x:400, y:400}, {x:600, y:600}, {x:400, y:800}, {x:200, y:600}], color:'#08AEEA'},

{p:[{x:400, y:400}, {x:600, y:600}, {x:600, y:200}], color:'#FA709A'},

{p:[{x:600, y:600}, {x:600, y:200}, {x:800, y:0}, {x:800, y:400}], color:'#2AF598'},

];

function draw(pieces, ctx){

ctx.save();

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

ctx.beginPath();

ctx.moveTo(pieces[i].p[0].x, pieces[i].p[0].y);

for(var j = 1 ; j < pieces[i].p.length ; j++){

ctx.lineTo(pieces[i].p[j].x, pieces[i].p[j].y);

}

ctx.closePath();

ctx.fillStyle = pieces[i].color;

ctx.fill();

}

}


draw(pieces, ctx);//這個(gè)是第一個(gè)html文件的canvas



var canvas1 = document.getElementById('myCanvas1');

var ctx1 = canvas1.getContext('2d');

function draw1(){

ctx1.translate(400, 400);

ctx1.beginPath();

ctx1.arc(0, 0, 200, 0, 2 * Math.PI, false);

ctx1.lineWidth = 5;

ctx1.strokeStyle = '#BE0707';

ctx1.stroke();

ctx.restore();

}


draw1();//這個(gè)是第二個(gè)html文件的canvas,畫不出來


正在回答

1 回答

這個(gè)是代碼

var canvas = document.getElementById('myCanvas');


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


var pieces = [

{p:[{x:0, y:0}, {x:400, y:400}, {x:0, y:800}], color:'#FF0000'},

{p:[{x:0, y:0}, {x:400, y:400}, {x:800, y:0}], color:'#FFE32C'},

{p:[{x:0, y:800}, {x:200, y:600}, {x:400, y:800}], color:'#21D4FD'},

{p:[{x:400, y:800}, {x:800, y:400}, {x:800, y:800}], color:'#FAACA8'},

{p:[{x:400, y:400}, {x:600, y:600}, {x:400, y:800}, {x:200, y:600}], color:'#08AEEA'},

{p:[{x:400, y:400}, {x:600, y:600}, {x:600, y:200}], color:'#FA709A'},

{p:[{x:600, y:600}, {x:600, y:200}, {x:800, y:0}, {x:800, y:400}], color:'#2AF598'},


];



function draw(pieces, ctx){

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

ctx.beginPath();

ctx.moveTo(pieces[i].p[0].x, pieces[i].p[0].y);

for(var j = 1 ; j < pieces[i].p.length ; j++){

ctx.lineTo(pieces[i].p[j].x, pieces[i].p[j].y);

}

ctx.closePath();

ctx.fillStyle = pieces[i].color;

ctx.fill();

}

}


draw(pieces, ctx);



var canvas1 = document.getElementById('myCanvas1');

var ctx1 = canvas1.getContext('2d');

function draw1(){

ctx1.translate(400, 400);

ctx1.beginPath();

ctx1.arc(0, 0, 200, 0, 2 * Math.PI, false);

ctx1.lineWidth = 5;

ctx1.strokeStyle = '#BE0707';

ctx1.stroke();

}


draw1();


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

舉報(bào)

0/150
提交
取消

兩個(gè)html文件分別放一個(gè)canvas,用同一個(gè)js文件,第二個(gè)html文件的canvas畫不出畫是咋回事?

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

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

幫助反饋 APP下載

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

公眾號

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