Explorar o código

Merge pull request #1936 from nockawa/centerMarginBug

Canvas2D: Positioning Bug fixing
Loïc Baumann %!s(int64=8) %!d(string=hai) anos
pai
achega
4a4482de42

+ 4 - 4
canvas2D/src/Engine/babylon.prim2dBase.ts

@@ -1195,8 +1195,8 @@
                             rightPixels = this.rightPixels;
                         }
 
-                        let center = ((sourceArea.width - (leftPixels+rightPixels)) - (width * sx)) / 2;
-                        dstOffset.x = leftPixels + center;
+                        let center = ((sourceArea.width - (width * sx)) / 2);
+                        dstOffset.x = center + (leftPixels - rightPixels);
 
                         if (computeLayoutArea) {
                             dstArea.width = (width * isx) + (this.leftPixels + this.rightPixels) * isx;
@@ -1295,8 +1295,8 @@
                             topPixels = this.topPixels;
                         }
 
-                        let center = ((sourceArea.height - (bottomPixels+topPixels)) - (height * sy)) / 2;
-                        dstOffset.y = bottomPixels + center;
+                        let center = ((sourceArea.height - (height * sy)) / 2);
+                        dstOffset.y = center + (bottomPixels - topPixels);
 
                         if (computeLayoutArea) {
                             dstArea.height = (height * isy) + (bottomPixels + topPixels) * isy;

+ 4 - 4
dist/preview release/canvas2D/babylon.canvas2d.js

@@ -6799,8 +6799,8 @@ var BABYLON;
                                 this._computePixels(2, sourceArea, true);
                                 rightPixels = this.rightPixels;
                             }
-                            var center = ((sourceArea.width - (leftPixels + rightPixels)) - (width * sx)) / 2;
-                            dstOffset.x = leftPixels + center;
+                            var center = ((sourceArea.width - (width * sx)) / 2);
+                            dstOffset.x = center + (leftPixels - rightPixels);
                             if (computeLayoutArea) {
                                 dstArea.width = (width * isx) + (this.leftPixels + this.rightPixels) * isx;
                             }
@@ -6888,8 +6888,8 @@ var BABYLON;
                                 this._computePixels(0, sourceArea, true);
                                 topPixels = this.topPixels;
                             }
-                            var center = ((sourceArea.height - (bottomPixels + topPixels)) - (height * sy)) / 2;
-                            dstOffset.y = bottomPixels + center;
+                            var center = ((sourceArea.height - (height * sy)) / 2);
+                            dstOffset.y = center + (bottomPixels - topPixels);
                             if (computeLayoutArea) {
                                 dstArea.height = (height * isy) + (bottomPixels + topPixels) * isy;
                             }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/canvas2D/babylon.canvas2d.min.js