1.简述API
2.Cavans
e.g.画一个三角形
Canvas* {
margin: 0;
padding: 0;
border: none;
}
canvas {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: block;
margin: auto;
background: #ececec;
}
window.onload = function() {
// 在此完成任务
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
context.moveTo(100,100);
context.lineTo(400,100);
context.stroke();
context.moveTo(100,100);
context.lineTo(100,500);
context.stroke();
context.moveTo(100,500);
context.lineTo(400,100);
context.stroke();
};
注意,浏览器推荐使用Chrome!
效果如下: