自己写啦一边不行,把代码改的一模一样还是不行,下载代码就是行的。又把下载的代码复制倒自己代码里注解里我自己的代码,还是不行。现在和下载的代码一模一样里还是不行。捣鼓里一下午里醉里
2016-12-17
{p:[{x:200,y:600},{x:400,y:800},{x:0,y:800}],color:"blue"}, 还少了一块,现在成了八巧板
2016-12-14
function draw(piece, context) {
context.beginPath();
context.moveTo(piece.p[0].x , piece.p[0].y);
for (var i = 1; i<piece.p.length; i++) {
context.lineTo(piece.p[i].x , piece.p[i].y);
}
context.closePath();
context.beginPath();
context.moveTo(piece.p[0].x , piece.p[0].y);
for (var i = 1; i<piece.p.length; i++) {
context.lineTo(piece.p[i].x , piece.p[i].y);
}
context.closePath();
2016-12-14
window.onload = function () {
var canvas = document.getElementById("canvas");
canvas.width = 700;
canvas.height = 600;
var context = canvas.getContext("2d");
for (var i=0; i<tangram.length; i++) {
draw(tangram[i], context);
}
};
var canvas = document.getElementById("canvas");
canvas.width = 700;
canvas.height = 600;
var context = canvas.getContext("2d");
for (var i=0; i<tangram.length; i++) {
draw(tangram[i], context);
}
};
2016-12-14
{p:[{x:600,y:200},{x:600,y:600},{x:400,y:400}],color:"red"},
{p:[{x:400,y:400},{x:600,y:600},{x:400,y:800},{x:200,y:600}],color:"purple"},
{p:[{x:800,y:400},{x:800,y:800},{x:400,y:800}],color:"orange"}
{p:[{x:400,y:400},{x:600,y:600},{x:400,y:800},{x:200,y:600}],color:"purple"},
{p:[{x:800,y:400},{x:800,y:800},{x:400,y:800}],color:"orange"}
2016-12-14
{p:[{x:0,y:0},{x:800,y:0},{x:800,y:200},{x:400,y:400}],color:"black"},
{p:[{x:0,y:0},{x:800,y:400},{x:400,y:400}],color:"grey"},
{p:[{x:0,y:0},{x:400,y:400},{x:0,y:800}],color:"yellow"},
{p:[{x:800,y:0},{x:800,y:400},{x:600,y:600},{x:600,y:200}],color:"cyan"},
{p:[{x:0,y:0},{x:800,y:400},{x:400,y:400}],color:"grey"},
{p:[{x:0,y:0},{x:400,y:400},{x:0,y:800}],color:"yellow"},
{p:[{x:800,y:0},{x:800,y:400},{x:600,y:600},{x:600,y:200}],color:"cyan"},
2016-12-14