标签:
<!DOCTYPE html>
<html lang=‘zh-cn‘>
<head>
<title>Insert you title</title>
<meta name=‘description‘ content=‘this is my page‘>
<meta name=‘keywords‘ content=‘keyword1,keyword2,keyword3‘>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel=‘stylesheet‘ type=‘text/css‘ href=‘./css/index.css‘ />
<script type=‘text/javascript‘ src=‘./js/jquery-1.12.1.min.js‘></script>
<style type=‘text/css‘>
html,body {
margin: 0; padding: 0;
}
html {
background: #999; height: 100%;
}
#can {
background: #FFF; display: block; margin: 75px auto; border-radius: 2px;
}
</style>
<script type=‘text/javascript‘>
$( function(){
var canvas = $( ‘#can‘ ).get( 0 );
var oCan = canvas.getContext( ‘2d‘ );
var img = new Image(); /* 新建图片对象 */
img.src = ‘./images/bg.jpg‘;
img.onload = drawImage; /* 图片预加载技术 */
function drawImage(){
oCan.drawImage( img , 250 - 99 , 250 - 127 , 198 , 254 );
}
} );
</script>
</head>
<body>
<canvas id=‘can‘ width=‘500‘ height=‘500‘>您的浏览器版本过低,请升级您的浏览器以获取更好的用户体验...</canvas>
</body>
</html>
[ html drawImage 绘制图片 ] canvas绘制图片 drawImage 属性实例演示
标签:
原文地址:http://www.cnblogs.com/mysearchblog/p/5762394.html