So, I have created a wrapper class, which sits over the top of Canvas, and should behave exactly the same, except you now have a getTransform() method which returns a matrix such that the following doesn't do anything:
var m = ctx.getTransform(); ctx.setTransform( m, m, m, m, m, m );To use, add the following line:
ctx = new CanvasWrapper(document.getElementById("canvas").getContext("2d"));It works by duplicating Canvas' matrix operations, and mimicking the Canvas interface. An annoyance is that Canvas has public fields, instead of accessor methods, so I can't tell when it has been changed and have to update the canvas state before any drawing call.
Update 10/2/2013: Thanks to Heikki Pora for a patch adding some missing features.
Update 19/5/2015: The HTML Spec now includes context.currentTransform but it doesn't work for me in Firefox or Chromium, ctx.mozCurrentTransform does work in Firefox.