Browse Source

Fixing pattern canvas transform for chrome

Yury Delendik 12 years ago
parent
commit
d7808b0db6
  1. 7
      src/canvas.js
  2. 5
      src/pattern.js

7
src/canvas.js

@ -57,6 +57,7 @@ function addContextCurrentTransform(ctx) { @@ -57,6 +57,7 @@ function addContextCurrentTransform(ctx) {
ctx._originalScale = ctx.scale;
ctx._originalTranslate = ctx.translate;
ctx._originalTransform = ctx.transform;
ctx._originalSetTransform = ctx.setTransform;
ctx._transformMatrix = [ctx._scaleX, 0, 0, ctx._scaleY, 0, 0];
ctx._transformStack = [];
@ -138,6 +139,12 @@ function addContextCurrentTransform(ctx) { @@ -138,6 +139,12 @@ function addContextCurrentTransform(ctx) {
ctx._originalTransform(a, b, c, d, e, f);
};
ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
this._transformMatrix = [a, b, c, d, e, f];
ctx._originalSetTransform(a, b, c, d, e, f);
};
ctx.rotate = function ctxRotate(angle) {
var cosValue = Math.cos(angle);
var sinValue = Math.sin(angle);

5
src/pattern.js

@ -351,6 +351,9 @@ var TilingPattern = (function TilingPatternClosure() { @@ -351,6 +351,9 @@ var TilingPattern = (function TilingPatternClosure() {
// set the new canvas element context as the graphics context
var tmpCtx = tmpCanvas.getContext('2d');
// for simulated mozCurrentTransform canvas (normaly setting width/height
// will reset the matrix)
tmpCtx.setTransform(1, 0, 0, 1, 0, 0);
var graphics = new CanvasGraphics(tmpCtx, commonObjs, objs);
this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
@ -415,7 +418,7 @@ var TilingPattern = (function TilingPatternClosure() { @@ -415,7 +418,7 @@ var TilingPattern = (function TilingPatternClosure() {
// The temporary canvas is created only because the memory is released
// more quickly than creating multiple temporary canvases.
if (temporaryPatternCanvas === null) {
temporaryPatternCanvas = createScratchCanvas(0, 0);
temporaryPatternCanvas = createScratchCanvas(1, 1);
}
this.createPatternCanvas(temporaryPatternCanvas);

Loading…
Cancel
Save