fix canvas transform bug (#3227)

This commit is contained in:
Knox
2018-09-11 11:39:27 +08:00
committed by pandamicro
parent 747b74ae0f
commit 604f4bd2ce
8 changed files with 12 additions and 14 deletions
@@ -50,6 +50,7 @@ RenderComponentWalker.prototype = {
let ctx = this._device._ctx;
let cam = this._camera;
ctx.setTransform(cam.a, cam.b, cam.c, cam.d, cam.tx, cam.ty);
ctx.scale(1, -1);
assembler.draw(ctx, comp);
},
@@ -36,10 +36,8 @@ module.exports = {
let matrix = node._worldMatrix;
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
tx = matrix.m12, ty = matrix.m13;
ctx.transform(a, b, c, d, tx, -ty);
ctx.transform(a, b, c, d, tx, ty);
ctx.save();
ctx.scale(1, -1);
// TODO: handle blend function
@@ -79,7 +79,8 @@ module.exports = js.addon({
let matrix = node._worldMatrix;
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
tx = matrix.m12, ty = matrix.m13;
ctx.transform(a, b, c, d, tx, -ty);
ctx.transform(a, b, c, d, tx, ty);
ctx.scale(1, -1);
// TODO: handle blend function
@@ -62,7 +62,8 @@ module.exports = js.addon({
let matrix = node._worldMatrix;
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
tx = matrix.m12, ty = matrix.m13;
ctx.transform(a, b, c, d, tx, -ty);
ctx.transform(a, b, c, d, tx, ty);
ctx.scale(1, -1);
// TODO: handle blend function
@@ -30,12 +30,6 @@ let beforeHandler = {
updateRenderData (comp) {},
draw (ctx, mask) {
let node = mask.node;
// Transform
let matrix = node._worldMatrix;
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
tx = matrix.m12, ty = matrix.m13;
ctx.save();
// draw stencil
@@ -123,7 +123,8 @@ let renderer = {
let matrix = node._worldMatrix;
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
tx = matrix.m12, ty = matrix.m13;
ctx.transform(a, b, c, d, tx, -ty);
ctx.transform(a, b, c, d, tx, ty);
ctx.scale(1, -1);
// TODO: handle blend function
@@ -116,7 +116,8 @@ let renderer = {
let matrix = node._worldMatrix;
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
tx = matrix.m12, ty = matrix.m13;
ctx.transform(a, b, c, d, tx, -ty);
ctx.transform(a, b, c, d, tx, ty);
ctx.scale(1, -1);
// TODO: handle blend function
@@ -44,7 +44,8 @@ let renderer = {
let matrix = node._worldMatrix;
let a = matrix.m00, b = matrix.m01, c = matrix.m04, d = matrix.m05,
tx = matrix.m12, ty = matrix.m13;
ctx.transform(a, b, c, d, tx, -ty);
ctx.transform(a, b, c, d, tx, ty);
ctx.scale(1, -1);
// TODO: handle blend function