首页 > 其他 > 详细

【canvas】高级功能一 变形

时间:2015-04-20 20:30:16      阅读:230      评论:0      收藏:0      [点我收藏+]

【canvas】Demo1 scale缩放

技术分享

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>图片</title>
</head>
<body>

<canvas id="wapper" width="1000" height="1000"></canvas>

<script>
var wapper = document.getElementById(‘wapper‘),
	_2d = wapper.getContext(‘2d‘);/*2d的绘制对象*/

var logo = new Image();
logo.src = ‘http://icon.xgo-img.com.cn/mainpage/20150226/logo_07.jpg‘;

logo.onload = function (){
	_2d.drawImage(this, 5, 5);/*drawImage(img,x,y)*/

	_2d.scale(1, 1);
	_2d.drawImage(this, 200, 5);/*drawImage(img,x,y)*/

	_2d.scale(2,2);
	_2d.drawImage(this, 0, 50);/*drawImage(img,x,y)*/

	_2d.scale(0.2,0.2);
	_2d.drawImage(this, 0, 800);/*drawImage(img,x,y)*/


}
</script>
</body>
</html>

  

【canvas】Demo2 translate移动

技术分享

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>图片</title>
</head>
<body>

<canvas id="wapper" width="1000" height="1000"></canvas>

<script>
var wapper = document.getElementById(‘wapper‘),
	_2d = wapper.getContext(‘2d‘);/*2d的绘制对象*/

_2d.fillRect(10,10,100,50);
_2d.translate(70,70);
_2d.fillRect(10,10,100,50);

</script>
</body>
</html>

  

【canvas】Demo3 rotate旋转

技术分享

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>rotate</title>
</head>
<body>

<canvas id="wapper" width="1000" height="1000"></canvas>

<script>
var wapper = document.getElementById(‘wapper‘),
	_2d = wapper.getContext(‘2d‘);/*2d的绘制对象*/

_2d.fillRect(50,50,100,50);
_2d.rotate(10*Math.PI/180);/*以画布0.0为中心的旋转*/
_2d.fillRect(50,50,100,50);
</script>
</body>
</html>

  

123

123

123

123

123

123

123

123

123

123

123

123

123

123

【canvas】高级功能一 变形

原文:http://www.cnblogs.com/dtdxrk/p/4442312.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!