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

<!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>
时间: 2024-10-25 19:38:02

[ html drawImage 绘制图片 ] canvas绘制图片 drawImage 属性实例演示的相关文章

[ html canvas save restore ] canvas绘图 save restore 属性实例演示

解析: 我们可以在做平移变换之前将当前canvas的状态进行保存,其实Canvas为 我们提供了图层(Layer)的支持,而这些Layer(图层)是按"栈结构"来进行管理的 当我们调用save()方法,会保存当前Canvas的状态然后作为一个Layer(图层),添加到Canvas栈中, 另外,这个Layer(图层)不是一个具体的类,就是一个概念性的东西而已! 而当我们调用restore()方法的时候,会恢复之前Canvas的状态,而此时Canvas的图层栈 会弹出栈顶的那个Layer,

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

1 <!DOCTYPE html> 2 <html lang='zh-cn'> 3 <head> 4 <title>Insert you title</title> 5 <meta name='description' content='this is my page'> 6 <meta name='keywords' content='keyword1,keyword2,keyword3'> 7 <meta htt

[ html drawImage 图片预加载 ] canvas绘制图片 drawImage 属性实例演示之三--使用New Image()进行图片预加载

1 <!DOCTYPE html> 2 <html lang='zh-cn'> 3 <head> 4 <title>Insert you title</title> 5 <meta name='description' content='this is my page'> 6 <meta name='keywords' content='keyword1,keyword2,keyword3'> 7 <meta htt

[ html canvas 绘制曲线三种方法 ] canvas绘图 绘制曲线三种方法属性实例演示

1 <!DOCTYPE html> 2 <html lang='zh-cn'> 3 <head> 4 <title>Insert you title</title> 5 <meta name='description' content='this is my page'> 6 <meta name='keywords' content='keyword1,keyword2,keyword3'> 7 <meta htt

[ html canvas 绘制文本 ] canvas绘图实现绘制文本 strokeText fillText方法及textAlign textBaseline font 属性实例演示

1 <!DOCTYPE html> 2 <html lang='zh-cn'> 3 <head> 4 <title>Insert you title</title> 5 <meta name='description' content='this is my page'> 6 <meta name='keywords' content='keyword1,keyword2,keyword3'> 7 <meta htt

[ html canvas 旋转 缩放 平移 ] canvas绘图实现旋转复制实例演示

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

[ html 绘图 translate ] canvas绘图属性translate 设置画布中心点属性实例演示

1 <!DOCTYPE html> 2 <html lang='zh-cn'> 3 <head> 4 <title>Insert you title</title> 5 <meta name='description' content='this is my page'> 6 <meta name='keywords' content='keyword1,keyword2,keyword3'> 7 <meta htt

[ html 绘图 translate roteta ] canvas绘图属性translate 设置画布中心点 rotate 旋转属性实例演示

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

[ html 绘图 strokeRect() fillRect() clearRect() ] canvas绘图strokeRect() fillRect() clearRect() 实例演示

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