Skip to content

Commit

Permalink
Add Container.pivoted utility
Browse files Browse the repository at this point in the history
  • Loading branch information
hubol committed Jul 23, 2024
1 parent c229c4c commit 2ee98b8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib/extensions/pixi-displayobject-convenience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ declare module "pixi.js" {
}

interface Container {
pivoted(vector: VectorSimple): this;
pivoted(x: number, y: number): this;
sized(vector: VectorSimple): this;
sized(width: number, height: number): this;
removeAllChildren();
Expand Down Expand Up @@ -52,6 +54,16 @@ Object.defineProperties(DisplayObject.prototype, {
return this;
}
},
pivoted: {
value: function (this: Container, x_vector: number | VectorSimple, y?: number) {
if (y === undefined)
this.transform.pivot.set((<VectorSimple>x_vector).x, (<VectorSimple>x_vector).y)
else
this.transform.pivot.set(<number>x_vector, y);

return this;
}
},
scaled: {
value: function (this: Container, scaleX_vector: number | VectorSimple, scaleY?: number) {
if (scaleY === undefined)
Expand Down

0 comments on commit 2ee98b8

Please sign in to comment.