Iam searching for a solution, in html5-canvas how to clear the scale function? If I scaled a shape, for next shape it should not scale or scale less thank you
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
// first draw
ctx.strokeRect(5,5,25,15);
//scale
ctx.scale(2,2);
ctx.strokeRect(5,5,25,15);
// how to clear scale this ? It should draw like first
ctx.scale(-1,-1); // this is not working
ctx.strokeRect(5,5,25,15);
</script>
</body>
</html>
Since you scaled by 2, you can un-scale by 1/2
// first draw
ctx.strokeRect(5,5,25,15);
//scale
ctx.scale(2,2);
ctx.strokeRect(5,5,25,15);
// un-scale
ctx.scale(.5,.5); // unscale by 1/2
ctx.strokeRect(5,5,25,15);
Another example, if you had scaled by 3 you would unscale by 1/3
// scale
ctx.scale(3,3);
// unscale
ctx.scale(1/3,1/3);