blob: e2aa7ee164e70422796cf3b39047151d81e01521 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import { Deserializable } from "../client/util/SerializationHelper";
import { serializable, custom, createSimpleSchema, list, object, map } from "serializr";
import { ObjectField } from "./ObjectField";
import { Copy, ToScriptString } from "./FieldSymbols";
export enum InkTool {
None,
Pen,
Highlighter,
Eraser,
Scrubber
}
export interface PointData {
X: number;
Y: number;
}
export type InkData = Array<PointData>;
const pointSchema = createSimpleSchema({
X: true, Y: true
});
const strokeDataSchema = createSimpleSchema({
pathData: list(object(pointSchema)),
"*": true
});
@Deserializable("ink")
export class InkField extends ObjectField {
@serializable(list(object(strokeDataSchema)))
readonly inkData: InkData;
constructor(data: InkData) {
super();
this.inkData = data;
}
[Copy]() {
return new InkField(this.inkData);
}
[ToScriptString]() {
return "invalid";
}
}
|