4.2 HTML Canvas标签
1. Canvas画布 通常用js来描绘
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>Canvas</title> <script src="myjavascript.js"></script> </head> <body> </body> </html>
var CANVAS_WIDTH = 200; var CANVAS_HEIGHT = 200; var myCanvas; var myContext; window.onload = function () { createCanvas(); drawRect(); } function createCanvas(){ document.body.innerHTML = "<canvas id=\"mycanvas\" width=\"" + CANVAS_WIDTH + "\" height=\"" + CANVAS_HEIGHT + "\" ></canvas>"; myCanvas = document.getElementById("mycanvas"); myContext = myCanvas.getContext("2d"); } function drawRect(){ myContext.fillRect(0,0,200,200); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。