码迷,mamicode.com
首页 > Web开发 > 详细

[ html drawImage 绘制图片 ] canvas绘制图片 drawImage 属性实例演示

时间:2016-08-11 20:47:27      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:

<!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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!