diff options
author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-05-09 00:02:30 -0400 |
---|---|---|
committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-05-09 00:02:30 -0400 |
commit | 2f5f13946cf0a1ec87efddbfbbc6a9fd878da924 (patch) | |
tree | ea9ec90561f73ed1c977e0538699c5f53b3c4712 /src/fields/InkField.ts | |
parent | 0766ba00727e9e13ced2e16cfb049d49711fa738 (diff) | |
parent | fa4d377b53c9ca31d8900d9c11bd25be57025962 (diff) |
Merge branch 'nathan-starter' of https://github.com/brown-dash/Dash-Web into nathan-starter
Diffstat (limited to 'src/fields/InkField.ts')
-rw-r--r-- | src/fields/InkField.ts | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/fields/InkField.ts b/src/fields/InkField.ts index c4f5f7a24..46704eb2b 100644 --- a/src/fields/InkField.ts +++ b/src/fields/InkField.ts @@ -89,6 +89,17 @@ export class InkField extends ObjectField { [ToString]() { return 'InkField'; } + + public static getBounds(stroke: InkData, pad?: boolean) { + const padding = pad ? [-20000, 20000] : []; + const xs = [...padding, ...stroke.map(p => p.X)]; + const ys = [...padding, ...stroke.map(p => p.Y)]; + const right = Math.max(...xs); + const left = Math.min(...xs); + const bottom = Math.max(...ys); + const top = Math.min(...ys); + return { right, left, bottom, top, width: right - left, height: bottom - top }; + } } ScriptingGlobals.add('InkField', InkField); |