Skip to content

Commit

Permalink
Fix bug in scale calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
samwho committed Mar 24, 2024
1 parent ebfe449 commit adbd5ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@

const g1 = new Graphics();
g1.beginFill(0xff0000);
g1.drawRect(0, 0, 100, 100);
g1.drawRect(0, 0, 100, 50);
g1.endFill();
g1.pivot.set(50, 50);
g1.pivot.set(50, 25);

const g2 = new Graphics();
g2.beginFill(0xff0000);
g2.drawRect(0, 0, 50, 100);
g2.drawRect(0, 0, 50, 50);
g2.endFill();
g2.pivot.set(25, 50);
g2.pivot.set(25, 25);

g2.getLayoutWidth = () => 50;
g2.getLayoutHeight = () => 50;

let component = HStack(Leaf(g1), Leaf(g2))
.proportions(2, 1)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixijs-layout",
"version": "0.1.24",
"version": "0.1.25",
"description": "",
"main": "./out/index.js",
"types": "./out/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/Leaf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ export class LeafComponent extends Container implements Positioner {
width = this._child.getLayoutWidth();
height = this._child.getLayoutHeight();
} else {
width = this._child.width;
height = this._child.height;
width = this._child.width / this._child.scale.x;
height = this._child.height / this._child.scale.y;
}
const originalWidth = width;
const originalHeight = height;
Expand Down

0 comments on commit adbd5ed

Please sign in to comment.