HTML5闪存
先看个Hello World吧。
大气象
大气象

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HTML5 Hello World</title>
<script type="text/javascript">
function f() {
var canvas = document.getElementById('panel');
var ctx = canvas.getContext("2d");//取得canvas对象
ctx.clearRect(0, 0, 200, 200);//清除一个区域
ctx.strokeStyle = "blue";//线色
ctx.strokeRect(10, 10, 180, 180);//画矩形
}
</script>
</head>
<body>
<canvas id="panel" width="200" height="200" style="background-color:red;">
你的浏览器不支持 Canvas 标签
</canvas>
<input type="button" value="画矩形" onclick="f();" />
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>HTML5 Hello World</title>
<script type="text/javascript">
function f() {
var canvas = document.getElementById('panel');
var ctx = canvas.getContext("2d");//取得canvas对象
ctx.clearRect(0, 0, 200, 200);//清除一个区域
ctx.strokeStyle = "blue";//线色
ctx.strokeRect(10, 10, 180, 180);//画矩形
}
</script>
</head>
<body>
<canvas id="panel" width="200" height="200" style="background-color:red;">
你的浏览器不支持 Canvas 标签
</canvas>
<input type="button" value="画矩形" onclick="f();" />
</body>
</html>
画基本图形

//画矩形区域
function fillRect() {
var canvas = document.getElementById('test1');
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 100, 200);
ctx.fillStyle = "blue";
ctx.fillRect(10, 10, 180, 180);
}
//画三角形
function drawTri(){
var canvas = document.getElementById('test2');
var ctx=canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(75,50);
ctx.lineTo(100,75);
ctx.lineTo(100,25);
ctx.fill();
}
function fillRect() {
var canvas = document.getElementById('test1');
var ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, 100, 200);
ctx.fillStyle = "blue";
ctx.fillRect(10, 10, 180, 180);
}
//画三角形
function drawTri(){
var canvas = document.getElementById('test2');
var ctx=canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(75,50);
ctx.lineTo(100,75);
ctx.lineTo(100,25);
ctx.fill();
}
每天学一点吧。
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。
分类:
web相关
· 一则复杂 SQL 改写后有感
· golang中写个字符串遍历谁不会?且看我如何提升 50 倍
· C# 代码如何影响 CPU 缓存速度?
· 智能桌面机器人:使用 .NET 为树莓派开发 Wifi 配网功能
· C# 模式匹配全解:原理、用法与易错点
· 一则复杂 SQL 改写后有感
· 曾经风光无限的 Oracle DBA 已经落伍了吗?
· 接口被刷百万QPS,怎么防?
· C# 锁机制全景与高效实践:从 Monitor 到 .NET 9 全新 Lock
· 一个开源免费、功能丰富的 WPF 自定义控件资源库
2010-01-25 Javascript四舍五入(Math.round()与Math.pow())