Reputation: 436
Is there any possibility of locking canvas
element? In my app I draw complex images and sometimes I use bitmaps. Using bitmaps with canvas isn't quite comfortable - all the drawing that should be placed on canvas after bitmap is placed in bitmaps .onload
.
It would be a lot easier if I could lock and unlock canvas
so it couldn't be updated for some time.
AFAIK there is no built-in function for lock/unlock. Do you know any simple way of implementing it?
Upvotes: 1
Views: 3292
Reputation: 7549
$("canvas").attr("disable","False");
// bitmap .onload...
$("canvas").attr("disable","True");
Or
bitmap.onload = function(){
var canvas = window.getCanvas();
});
Upvotes: 0
Reputation: 154838
I don't know whether this is bulletproof or not, but you could temporarily make .stroke
etc. noops: http://jsfiddle.net/eGjak/247/.
var toLock = "stroke fill".split(" ");
function lock() {
$.each(toLock, function(i, name) { // or another way to loop the array
ctx[name] = function() {};
});
}
function unlock() {
$.each(toLock, function(i, name) {
ctx[name] = ctx.constructor.prototype[name];
});
}
Upvotes: 1