HTML5 label canvas, Function DrawImage ():
Use the DrawImage () method to draw the image. The drawing environment provides three different versions of the method. Parameters are passed in three different forms:
DrawImage (Image,x,y): Draws a picture in the canvas (x, y).
DrawImage (Image,x,y,width,height): Draws the picture in the canvas (x, y) and zooms it to the specified width and height.
DrawImage (image,sourcex,sourcey,sourcewidth,sourceheight,x,y,width,height): Cut a rectangular area from the picture (Sourcex,sourcey, Sourcewidth,sourceheight), zooms to the specified width and height, and is drawn in the canvas (x, y).
Where image can be an existing DOM element in a page, obtained using document.getElementById ();
or use Document.createelement ("img") to create a new element, but the assignment src need to listen to the OnLoad event, callback call DrawImage, if the immediate call does not load complete, will not draw out the picture.
HTML5 label Canvas function DrawImage use method