分页: 1 / 1

Html5 Canvas 简单示例

发表于 : 2017年07月07日 15:52
vicyang
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Canvas</title>
</head>

<body onload="main()">
<canvas id="example1" width="400" height="400">
Please use a browser that supports "canvas"
</canvas>
<script>
function main()
{
var canvas = document.getElementById('example1');
if (! canvas )
{
console.log('Failed to retrieve the <canvas> element');
return;
}

var ctx = canvas.getContext('2d'); // 注意是小写'd'

ctx.fillStyle = 'rgba(0, 0, 255, 1.0)';
ctx.fillRect(120, 10, 150, 150);
}
</script>
</body>
</html>
在线浏览代码和效果
http://runjs.cn/code/8r9cqjly

Re: Html5 Canvas 简单示例

发表于 : 2017年07月17日 15:38
happy886rr
:look_around1 vicyang 应该是小号。

Re: Html5 Canvas 简单示例

发表于 : 2017年07月22日 11:57
PerlMonk
happy886rr 写了::look_around1 vicyang 应该是小号。
you are right

111