[ts][canvas] Cleanup

This commit is contained in:
badlogic 2017-03-02 11:09:45 +01:00
parent 3bb27040c4
commit f5b4310350
3 changed files with 9 additions and 13 deletions

View File

@ -242,17 +242,15 @@ var spine;
var bone = slot.bone;
var w = region.width;
var h = region.height;
var offsetX = attachment.offset[0];
var offsetY = attachment.offset[1];
ctx.save();
ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
ctx.translate(offsetX, offsetY);
ctx.translate(attachment.offset[0], attachment.offset[1]);
ctx.rotate(attachment.rotation * Math.PI / 180);
ctx.scale(attachment.scaleX, attachment.scaleY);
ctx.translate(region.width / 2, region.height / 2);
ctx.translate(w / 2, h / 2);
ctx.scale(1, -1);
ctx.translate(-region.width / 2, -region.height / 2);
ctx.drawImage(image, region.x, region.y, region.width, region.height, 0, 0, w, h);
ctx.translate(-w / 2, -h / 2);
ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
if (this.debugRendering)
ctx.strokeRect(0, 0, w, h);
ctx.restore();

File diff suppressed because one or more lines are too long

View File

@ -67,17 +67,15 @@ module spine.canvas {
let bone = slot.bone;
let w = region.width;
let h = region.height;
let offsetX = attachment.offset[0];
let offsetY = attachment.offset[1];
ctx.save();
ctx.transform(bone.a, bone.c, bone.b, bone.d, bone.worldX, bone.worldY);
ctx.translate(offsetX, offsetY);
ctx.translate(attachment.offset[0], attachment.offset[1]);
ctx.rotate(attachment.rotation * Math.PI / 180);
ctx.scale(attachment.scaleX, attachment.scaleY);
ctx.translate(region.width / 2, region.height / 2);
ctx.translate(w / 2, h / 2);
ctx.scale(1, -1);
ctx.translate(-region.width / 2, -region.height / 2);
ctx.drawImage(image, region.x, region.y, region.width, region.height, 0, 0, w, h);
ctx.translate(-w / 2, -h / 2);
ctx.drawImage(image, region.x, region.y, w, h, 0, 0, w, h);
if (this.debugRendering) ctx.strokeRect(0, 0, w, h);
ctx.restore();
}