2014-07-07 1 views

답변

2

주석 코드와 데모 : http://jsfiddle.net/m1erickson/asT8x/

// clear the canvas 

ctx.clearRect(0,0,canvas.width,canvas.height); 

// save the context state 

ctx.save(); 

// translate to the coordinate point you wish to zoom in on 

ctx.translate(mouseX,mouseY); 

// scale the canvas to the desired zoom level 

ctx.scale(scale,scale); 

// draw the image with an offset of -mouseX,-mouseY 
// (offset to center image at the selected zoom point); 

ctx.drawImage(img,-mouseX,-mouseY); 

// restore the context to its untranslated/unrotated state 

ctx.restore(); 
+0

좋아요 매우 ynice 그러나 나는 확대와 위치를 변경하려면이 예는 변화의 시작 위치를 위해 노력 – user3797449