javascript - HTML5 Canvas Scale position -


im trying out canvas first time , have few questions scaling.

after scale canvas (half) want set current position. scale sets canvas pos 0,0 (top-left).

if knows how change position while scaling please leave answer!

example
http://i.stack.imgur.com/slg4v.png original.
http://i.imgur.com/2nmjzjh.png needed result.

to have shown in images.

// ctx canvas 2d context // img image function showimagescaled(img,scale,x,y){     // scale how big want it.      // x , y in image want top left     ctx.settransform(scale,0,0,scale,0,0);     ctx.drawimage(img,-x,-y); // move image } 

so view top corner scaled twice

showimagescaled(img,2,0,0); 

to show centre in top left , image scaled 4 times

showimagescaled(img,4,img.width/2,img.height/2); 

hope helps.


Comments