From 794ab046314caf238d0f29e517ed04b3cd442282 Mon Sep 17 00:00:00 2001 From: Kevin Aelterman Date: Wed, 20 Mar 2024 10:22:29 +0100 Subject: [PATCH 1/4] Fixed BoundingBox imports. --- types.d.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/types.d.ts b/types.d.ts index 97fd5c51..9e903b26 100644 --- a/types.d.ts +++ b/types.d.ts @@ -1462,7 +1462,7 @@ declare module "two.js/src/group" { * @returns {Object} - Returns object with top, left, right, bottom, width, height attributes. * @description Return an object with top, left, right, bottom, width, and height parameters of the group. */ - getBoundingClientRect(shallow?: boolean): Two.BoundingBox; + getBoundingClientRect(shallow?: boolean): BoundingBox; /** * @name Two.Group#noFill * @function @@ -1494,6 +1494,7 @@ declare module "two.js/src/group" { import { Children } from "two.js/src/children"; import { Gradient } from "two.js/src/effects/gradient"; import { Texture } from "two.js/src/effects/texture"; + import { BoundingBox } from "two.js"; } declare module "two.js/src/renderers/canvas" { /** @@ -2469,7 +2470,7 @@ declare module "two.js/src/path" { * @returns {Object} - Returns object with top, left, right, bottom, width, height attributes. * @description Return an object with top, left, right, bottom, width, and height parameters of the path. */ - getBoundingClientRect(shallow?: boolean): Two.BoundingBox; + getBoundingClientRect(shallow?: boolean): BoundingBox; /** * @name Two.Path#getPointAt * @function @@ -2509,6 +2510,7 @@ declare module "two.js/src/path" { import { Shape } from "two.js/src/shape"; import { Gradient } from "two.js/src/effects/gradient"; import { Texture } from "two.js/src/effects/texture"; + import { BoundingBox } from "two.js"; /** * @name FlagVertices * @private @@ -3178,11 +3180,12 @@ declare module "two.js/src/text" { * @returns {Object} - Returns object with top, left, right, bottom, width, height attributes. * @description Return an object with top, left, right, bottom, width, and height parameters of the text object. */ - getBoundingClientRect(shallow?: boolean): Two.BoundingBox; + getBoundingClientRect(shallow?: boolean): BoundingBox; } import { Shape } from "two.js/src/shape"; import { Gradient } from "two.js/src/effects/gradient"; import { Texture } from "two.js/src/effects/texture"; + import { BoundingBox } from "two.js"; } declare module "two.js/src/utils/interpret-svg" { /** @@ -3553,7 +3556,7 @@ declare module "two.js/src/shapes/points" { * @returns {Object} - Returns object with top, left, right, bottom, width, height attributes. * @description Return an object with top, left, right, bottom, width, and height parameters of the path. */ - getBoundingClientRect: (shallow?: boolean) => Two.BoundingBox; + getBoundingClientRect: (shallow?: boolean) => BoundingBox; /** * @name Two.Points#subdivide * @function @@ -3574,6 +3577,7 @@ declare module "two.js/src/shapes/points" { import { Shape } from "two.js/src/shape"; import { Gradient } from "two.js/src/effects/gradient"; import { Texture } from "two.js/src/effects/texture"; + import { BoundingBox } from "two.js"; } declare module "two.js/src/shapes/polygon" { /** From a83484556f3218eb3f3877e7dccdd347d40d3032 Mon Sep 17 00:00:00 2001 From: Kevin Aelterman Date: Wed, 20 Mar 2024 11:48:04 +0100 Subject: [PATCH 2/4] Added Dimensions type. --- types.d.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/types.d.ts b/types.d.ts index 9e903b26..bfa67d9f 100644 --- a/types.d.ts +++ b/types.d.ts @@ -2943,6 +2943,14 @@ declare module "two.js/src/text" { * @property {String[]} - A list of properties that are on every {@link Two.Text}. */ static Properties: string[]; + /** + * @name Two.Measure + * @function + * @param {Two.Text} [text] - The instance of {@link Two.Text} to measure. + * @returns {Object} - The width and height of the {@link Two.Text} instance. + */ + static Measure(text: Text): Dimensions; + constructor(message?: string, x?: number, y?: number, styles?: any); /** * @name Two.Text#_flagValue @@ -3185,7 +3193,7 @@ declare module "two.js/src/text" { import { Shape } from "two.js/src/shape"; import { Gradient } from "two.js/src/effects/gradient"; import { Texture } from "two.js/src/effects/texture"; - import { BoundingBox } from "two.js"; + import { BoundingBox, Dimensions } from "two.js"; } declare module "two.js/src/utils/interpret-svg" { /** @@ -4485,7 +4493,10 @@ declare module "two.js" { top: number, left: number, right: number, - bottom: number, + bottom: number + } & Dimensions; + + export type Dimensions = { width: number, height: number } From 8684126e9cacdbadfdc846952551ffa66a53d4c2 Mon Sep 17 00:00:00 2001 From: Kevin Aelterman Date: Wed, 20 Mar 2024 11:48:04 +0100 Subject: [PATCH 3/4] Added Dimensions type. --- types.d.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/types.d.ts b/types.d.ts index 9e903b26..1c5f0547 100644 --- a/types.d.ts +++ b/types.d.ts @@ -3185,7 +3185,7 @@ declare module "two.js/src/text" { import { Shape } from "two.js/src/shape"; import { Gradient } from "two.js/src/effects/gradient"; import { Texture } from "two.js/src/effects/texture"; - import { BoundingBox } from "two.js"; + import { BoundingBox, Dimensions } from "two.js"; } declare module "two.js/src/utils/interpret-svg" { /** @@ -4485,7 +4485,10 @@ declare module "two.js" { top: number, left: number, right: number, - bottom: number, + bottom: number + } & Dimensions; + + export type Dimensions = { width: number, height: number } From 0c2bc69ae4a7b03d14bcf21c993a38375e27b40f Mon Sep 17 00:00:00 2001 From: Kevin Aelterman Date: Wed, 20 Mar 2024 12:11:51 +0100 Subject: [PATCH 4/4] Added definition for Two.Measure. --- types.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/types.d.ts b/types.d.ts index 1c5f0547..6617583b 100644 --- a/types.d.ts +++ b/types.d.ts @@ -2943,6 +2943,14 @@ declare module "two.js/src/text" { * @property {String[]} - A list of properties that are on every {@link Two.Text}. */ static Properties: string[]; + /** + * @name Two.Measure + * @function + * @param {Two.Text} [text] - The instance of {@link Two.Text} to measure. + * @returns {Object} - The width and height of the {@link Two.Text} instance. + */ + static Measure(text: Text): Dimensions; + constructor(message?: string, x?: number, y?: number, styles?: any); /** * @name Two.Text#_flagValue