canvas教程

HTML5 canvas drawImage()

字号+ 作者:H5之家 来源:H5之家 2018-03-07 15:04 我要评论( )

HTML5 canvas drawImage() Your browser does not support the HTML5 canvas tag. JavaScript: var c=document.getElementById(myCanvas);var ctx=c.getContext(2d);var img=document.getElementById(tulip);ctx.drawImage(img,10,10); Internet Explorer 9F

HTML5 canvas drawImage()

tulip

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); var img=document.getElementById("tulip"); ctx.drawImage(img,10,10);

Internet Explorer 9FirefoxOperaChrome Safari drawImage()

Internet Explorer 8 <canvas>

÷

drawImage()

drawImage() Щ/硣

JavaScript 1

λ

context.drawImage(img,x,y); JavaScript 2

λ涨

context.drawImage(img,x,y,width,height); JavaScript 3

λе

context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height);

img 涨

sx е x λá

sy е y λá

swidth

sheight

x x λá

y y λá

width С

height С

1

жλ涨

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); var img=document.getElementById("tulip"); ctx.drawImage(img,10,10,240,160); 2

ежλ

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); var img=document.getElementById("scream"); ctx.drawImage(img,90,130,90,80,20,20,90,80); 3 Your browser does not support the HTML5 canvas tag.

JavaScript 20

var v=document.getElementById("video1"); var c=document.getElementById("myCanvas"); ctx=c.getContext('2d'); v.addEventListener('play',function() {var i=window.setInterval(function() {ctx.drawImage(v,0,0,270,135)},20);},false); v.addEventListener('pause',function() {window.clearInterval(i);},false); v.addEventListener('ended',function() {clearInterval(i);},false);

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • HTML5 canvas createImageData()

    HTML5 canvas createImageData()

    2018-03-07 15:04

  • HTML5 canvas moveTo()

    HTML5 canvas moveTo()

    2018-03-07 14:30

  • canvas裁剪clip()函数的具体使用

    canvas裁剪clip()函数的具体使用

    2018-03-07 13:05

  • 一次canvas中文字转化成图片后清晰度丢失的探索

    一次canvas中文字转化成图片后清晰度丢失的探索

    2018-03-07 11:01

网友点评