DrawImage From Atlas

Created on Feb. 20, 2013, 11:58 a.m. by Hevok & updated by Hevok on May 2, 2013, 5:09 p.m.

After one has a Asset data parsed one can use it to render to the screen. The drawImage function allows to draw sub section of an Image. Effectively it takes the image object, source x and y positions and supports the ability to take a few more parameters giving more control on one want the pixels on the screen. It also takes the source width and height parameters. Together they represent the x, y position of the chat in the Atlas as well as the width and the height of that chart in the Atlas. The destination x, y, width and height represent the position and the size that this small subsection of the atlas is going to be drawn to in the output Canvas. For example, one can set source x and source y to 2, 2. Width and height to 32,32. And draw to a position on canvas of 128, 128 by 64, 63. drawImage is smart enough to know that if the source, width and height do not match the destination width and height to properly scale the Image to match the desired output size. In most cases the source and destination width and height are the same size.


Tags: web, draw, image
Categories: Tutorial
Parent: Drawing Image

Update entry (Admin) | See changes

Comment on This Data Unit