add optional outputCanvas to options object

This commit is contained in:
root 2009-10-05 10:19:53 +02:00
parent 61418d22f2
commit ef3a2bf34e

View file

@ -152,7 +152,9 @@ var Pixastic = (function() {
} }
var canvas, ctx; var canvas, ctx;
var hasOutputCanvas = false;
if (Pixastic.Client.hasCanvas()) { if (Pixastic.Client.hasCanvas()) {
hasOutCanvas = !!options.outputCanvas;
canvas = options.outputCanvas || document.createElement("canvas"); canvas = options.outputCanvas || document.createElement("canvas");
ctx = canvas.getContext("2d"); ctx = canvas.getContext("2d");
} }
@ -217,8 +219,10 @@ var Pixastic = (function() {
if (Pixastic.Client.hasCanvas()) { if (Pixastic.Client.hasCanvas()) {
canvas.width = w; canvas.width = w;
canvas.height = h; canvas.height = h;
canvas.style.width = w+"px"; if (!hasOutputCanvas) {
canvas.style.height = h+"px"; canvas.style.width = w+"px";
canvas.style.height = h+"px";
}
ctx.drawImage(dataImg,0,0,w,h); ctx.drawImage(dataImg,0,0,w,h);
if (!img.__pixastic_org_image) { if (!img.__pixastic_org_image) {
@ -258,6 +262,7 @@ var Pixastic = (function() {
canvas.getContext("2d").putImageData(params.canvasData, options.rect.left, options.rect.top); canvas.getContext("2d").putImageData(params.canvasData, options.rect.left, options.rect.top);
// Opera doesn't seem to update the canvas until we draw something on it, lets draw a 0x0 rectangle. // Opera doesn't seem to update the canvas until we draw something on it, lets draw a 0x0 rectangle.
// Is this still so?
canvas.getContext("2d").fillRect(0,0,0,0); canvas.getContext("2d").fillRect(0,0,0,0);
} }
} }