diff options
author | bobzel <zzzman@gmail.com> | 2021-12-10 13:36:12 -0500 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2021-12-10 13:36:12 -0500 |
commit | e54c1ef16b4ce0a324fac3747defdc6501834de5 (patch) | |
tree | e956e5bbe07e53a36e5ead3d637e6f7c2b01671b /src/fields/InkField.ts | |
parent | 8176b94970b86bd3c1669130f6fef2ccd70d0b84 (diff) | |
parent | f8ce34c8ed42646691d1e392effe79bc27daf810 (diff) |
Merge branch 'master' into ink_v1
Diffstat (limited to 'src/fields/InkField.ts')
-rw-r--r-- | src/fields/InkField.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/fields/InkField.ts b/src/fields/InkField.ts index f61313674..560cf3d63 100644 --- a/src/fields/InkField.ts +++ b/src/fields/InkField.ts @@ -3,7 +3,6 @@ import { Scripting } from "../client/util/Scripting"; import { Deserializable } from "../client/util/SerializationHelper"; import { Copy, ToScriptString, ToString } from "./FieldSymbols"; import { ObjectField } from "./ObjectField"; -import { DocumentView } from "../client/views/nodes/DocumentView"; import { Bezier } from "bezier-js"; // Helps keep track of the current ink tool in use. @@ -22,13 +21,6 @@ export interface PointData { Y: number; } -export interface Intersection { - t?: number; - ink?: DocumentView; - curve?: Bezier; - index?: number; -} - export type Segment = Array<Bezier>; // Defines an ink as an array of points. @@ -78,6 +70,14 @@ export class InkField extends ObjectField { this.inkData = data; } + /** + * Extacts a simple segment from a compound Bezier curve + * @param segIndex the start index of the simple bezier segment to extact (eg., 0, 4, 8, ...) + */ + public static Segment(inkData: InkData, segIndex: number) { + return new Bezier(inkData.slice(segIndex, segIndex + 4).map(pt => ({ x: pt.X, y: pt.Y }))); + } + [Copy]() { return new InkField(this.inkData); } |