欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2/Agda, C++/Lisp/Haskell
HTML5/canvas
来自开放百科 - 灰狐
(版本间的差异)
小 (→链接) |
小 |
||
| 第1行: | 第1行: | ||
| − | |||
{{SeeWikipedia|Canvas element}} | {{SeeWikipedia|Canvas element}} | ||
| 第5行: | 第4行: | ||
HTML5 Canvas 将在[[HTML5/game|HTML5游戏]]中扮演重要角色。 | HTML5 Canvas 将在[[HTML5/game|HTML5游戏]]中扮演重要角色。 | ||
| + | |||
| + | 第一个例子: | ||
| + | <html> | ||
| + | <head> | ||
| + | <script type="application/x-javascript"> | ||
| + | function draw() { | ||
| + | var canvas = document.getElementById("canvas"); | ||
| + | if (canvas.getContext) { | ||
| + | var ctx = canvas.getContext("2d"); | ||
| + | |||
| + | ctx.fillStyle = "rgb(200,0,0)"; | ||
| + | ctx.fillRect (10, 10, 55, 50); | ||
| + | |||
| + | ctx.fillStyle = "rgba(0, 0, 200, 0.5)"; | ||
| + | ctx.fillRect (30, 30, 55, 50); | ||
| + | } | ||
| + | } | ||
| + | </script> | ||
| + | </head> | ||
| + | <body onload="draw();"> | ||
| + | <canvas id="canvas" width="150" height="150"> | ||
| + | <p>This example requires a browser that supports the | ||
| + | <a href="http://www.w3.org/html/wg/html5/">HTML5</a> | ||
| + | <canvas> feature.</p> | ||
| + | |||
| + | </canvas> | ||
| + | </body> | ||
| + | </html> | ||
==项目== | ==项目== | ||
2011年2月13日 (日) 09:40的版本
| |
您可以在Wikipedia上了解到此条目的英文信息 HTML5/canvas Thanks, Wikipedia. |
Convas 是 HTML5 的一部分,它支持动态生成与渲染2D图形、图表、图像和动画。
HTML5 Canvas 将在HTML5游戏中扮演重要角色。
第一个例子: <html>
<head>
<script type="application/x-javascript">
function draw() {
var canvas = document.getElementById("canvas");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(200,0,0)";
ctx.fillRect (10, 10, 55, 50);
ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
ctx.fillRect (30, 30, 55, 50);
}
}
</script>
</head>
<body onload="draw();">
<canvas id="canvas" width="150" height="150">
This example requires a browser that supports the <a href="http://www.w3.org/html/wg/html5/">HTML5</a> <canvas> feature.
</canvas> </body>
</html>
项目
链接
- HTML5: The Canvas Element
- HTML Canvas 2D Context
- Canvas tutorial on Mozzila.org
- HTML5 canvas - the basics on Opera
<discussion>characters_max=300</discussion>
分享您的观点