2020-03-17 20:55:40 +01:00
|
|
|
import { Point } from "../types";
|
|
|
|
|
|
|
|
type _ExcalidrawElementBase = Readonly<{
|
|
|
|
id: string;
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
strokeColor: string;
|
|
|
|
backgroundColor: string;
|
|
|
|
fillStyle: string;
|
|
|
|
strokeWidth: number;
|
|
|
|
roughness: number;
|
|
|
|
opacity: number;
|
|
|
|
width: number;
|
|
|
|
height: number;
|
2020-04-02 17:40:26 +09:00
|
|
|
angle: number;
|
2020-03-17 20:55:40 +01:00
|
|
|
seed: number;
|
|
|
|
version: number;
|
|
|
|
versionNonce: number;
|
|
|
|
isDeleted: boolean;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type ExcalidrawGenericElement = _ExcalidrawElementBase & {
|
|
|
|
type: "selection" | "rectangle" | "diamond" | "ellipse";
|
|
|
|
};
|
2020-01-06 19:34:22 +04:00
|
|
|
|
2020-03-08 10:20:55 -07:00
|
|
|
/**
|
|
|
|
* ExcalidrawElement should be JSON serializable and (eventually) contain
|
|
|
|
* no computed data. The list of all ExcalidrawElements should be shareable
|
|
|
|
* between peers and contain no state local to the peer.
|
|
|
|
*/
|
2020-03-17 20:55:40 +01:00
|
|
|
export type ExcalidrawElement =
|
|
|
|
| ExcalidrawGenericElement
|
|
|
|
| ExcalidrawTextElement
|
|
|
|
| ExcalidrawLinearElement;
|
2020-03-09 22:34:50 -07:00
|
|
|
|
2020-03-17 20:55:40 +01:00
|
|
|
export type ExcalidrawTextElement = _ExcalidrawElementBase &
|
2020-03-10 20:11:02 -07:00
|
|
|
Readonly<{
|
|
|
|
type: "text";
|
|
|
|
font: string;
|
|
|
|
text: string;
|
|
|
|
baseline: number;
|
|
|
|
}>;
|
2020-03-09 22:34:50 -07:00
|
|
|
|
2020-03-17 20:55:40 +01:00
|
|
|
export type ExcalidrawLinearElement = _ExcalidrawElementBase &
|
|
|
|
Readonly<{
|
|
|
|
type: "arrow" | "line";
|
|
|
|
points: Point[];
|
2020-03-18 16:43:06 +01:00
|
|
|
lastCommittedPoint?: Point | null;
|
2020-03-17 20:55:40 +01:00
|
|
|
}>;
|
|
|
|
|
2020-02-21 14:34:18 -05:00
|
|
|
export type PointerType = "mouse" | "pen" | "touch";
|