diff options
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); |