canvas学习(二)
2014-02-04 22:16
337 查看
html文件:
<!DOCTYPE html>
<html>
<head>
<title>A simple canvas Example</title>
<style>
body{
background: #dddddd;
}
#canvas {
margin: 10px;
padding: 10px;
background: #ffffff;
border: thin inset #aaaaaa;
width:800px;
height:300px;
}
</style>
</head>
<body>
<canvas id = 'canvas' width = '600' height = '300'>
Canvas not supported
</canvas>
<script src = 'example.js'></script>
</body>
</html>
example.js
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d');
context.font = '18px Arial';
context.fillStyle = 'cornflowerblue';
context.strokeStyle = 'green';
context.fillText('Hello Canvas1',canvas.width/2 - 111,
canvas.height/2 + 15);
context.font = '38px Arial';
context.strokeStyle = 'yellow';
context.strokeText('Hello Canvas22',canvas.width/2 - 150,
canvas.height/2 + 150);
<!DOCTYPE html>
<html>
<head>
<title>A simple canvas Example</title>
<style>
body{
background: #dddddd;
}
#canvas {
margin: 10px;
padding: 10px;
background: #ffffff;
border: thin inset #aaaaaa;
width:800px;
height:300px;
}
</style>
</head>
<body>
<canvas id = 'canvas' width = '600' height = '300'>
Canvas not supported
</canvas>
<script src = 'example.js'></script>
</body>
</html>
example.js
var canvas = document.getElementById('canvas'),
context = canvas.getContext('2d');
context.font = '18px Arial';
context.fillStyle = 'cornflowerblue';
context.strokeStyle = 'green';
context.fillText('Hello Canvas1',canvas.width/2 - 111,
canvas.height/2 + 15);
context.font = '38px Arial';
context.strokeStyle = 'yellow';
context.strokeText('Hello Canvas22',canvas.width/2 - 150,
canvas.height/2 + 150);
相关文章推荐
- [一个星期自学安卓]手机网页空间WebView
- 浙江大学ACM俱乐部 1022:挂盐水
- [一个星期自学安卓]单选控件RadioButton及复选控件CheckBox
- 开始学习算法
- OCP-1Z0-053-200题-165题-141
- 黑马程序员_19GUI简述
- 浙江大学ACM俱乐部 1021:恶搞指数
- canvas学习(一)
- !function($){}(window.jQuery)
- 浙江大学ACM俱乐部 1020:电梯升降
- centos安装多个nginx之后出现的问题及解决方案
- 朝鲜推出"红星OS" 疑似全盘抄袭Mac OS
- yum服务器的安装及配置
- 浙江大学ACM俱乐部 1019:石头剪子布
- hdu1114(完全背包+恰好装满)
- ntp服务器安装及配置
- 改变脚本运行的路径
- linux下oracle设置开机自启动实现方法
- Linux下常用命令
- perl hash 按value/按keys 排序(多种方法)