-
Notifications
You must be signed in to change notification settings - Fork 1
/
raska.d.ts
121 lines (112 loc) · 4.03 KB
/
raska.d.ts
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS FILE IS JUST FOR REFERENCE WHEN WRITING/COMPILING TYPESCRIPT CODE
/// DO NOT DEPLOY IT TO PRODUCTION!
/////////////////////////////////////////////////////////////////////////////////////////////////////////
interface raskaNodeEvents {
click(x: number, y: number, ele: raskaNode, evt: string): raskaNodeEvents;
release(x: number, y: number, ele: raskaNode, evt: string): raskaNodeEvents;
}
interface raskaNode {
attr: any;
name: string;
getType(): string;
canLink(): boolean;
graphNode: boolean;
disable(): raskaNode;
notifyDisableStateOn(node: raskaNode): raskaNode;
elementDisabledNotification(): raskaNode;
canReach(node: raskaNode): boolean;
isLinkable(): boolean;
canBeMoved(): boolean;
isSerializable(): boolean;
addLinkTo(node: raskaNode): boolean;
removeLinkFrom(node: raskaNode): raskaNode;
addLinkFrom(node: raskaNode): boolean;
removeLinkTo(node: raskaNode): raskaNode;
beforeRemoveLinkTo(doWhat: () => {}): raskaNode;
normalize(): raskaNode;
getLinksTo(): Array<raskaNode>;
getLinksFrom(): Array<raskaNode>;
clearAllLinks(): raskaNode;
getChildElements(): Array<raskaNode>;
addChild(node: raskaNode): raskaNode;
getParent(): raskaNode;
getBoundaries(): { x: number; y: number; minX: number; minY: number };
setParent(node: raskaNode): raskaNode;
border: {
color: string;
whenMoving: { color?: string; active: boolean };
whenLinking: { color?: string; active: boolean };
active: boolean;
width: number;
};
position: any;
x: number;
y: number;
getAdjustedCoordinates(): { x: number; y: number };
canHandleEvents(): boolean;
on: raskaNodeEvents;
existsIn(x: number, y: number): boolean;
adjustPosition(x: number, y: number): raskaNode;
setWidth(w: number): raskaNode;
getWidth(): number;
getAdjustedWidth(): number;
setHeight(h: number): raskaNode;
getHeight(): number;
getAdjustedHeight(): number;
drawTo(canvas: HTMLCanvasElement, context: any);
}
interface raskaButton {
name: string;
enabled: boolean;
onclick: (canvas: string) => {};
template: string;
}
interface raskaConfiguration {
targetCanvasId: string;
readonly?: boolean;
frameRefreshRate?: number;
targetCanvasContainerId?: string;
toolboxButtons?: Array<raskaButton>;
}
interface raskaEventDetail {
interactionType: number;
targetElement: raskaNode;
}
interface raskaAnimationType {
fadeInWithBoudaries(maxValues: { maxWidth: number; maxHeight: number }): raskaAnimationType;
fadeIn(step?: number, maxValues?: { maxWidth: number; maxHeight: number }): raskaAnimationType;
fadeOut(step?: number): raskaAnimationType;
move(configuration?: (x: number, y: number) => { x: number; y: number }): raskaAnimationType;
then(what: { execute: () => any }): raskaAnimationType;
loop(): raskaAnimationType;
saveInitialStates(): raskaAnimationType;
stop(): raskaAnimationType;
execute(interval?: number): raskaAnimationType;
}
interface raskaAnimation {
on(node: raskaNode): raskaAnimationType;
}
interface Raska {
installUsing(configuration: raskaConfiguration): Raska;
newCircle(): raskaNode;
newLabel(): raskaNode;
newSquare(): raskaNode;
newTriangle(): raskaNode;
plot(node: raskaNode): Raska;
exportImage(): Raska;
getElementsRaw(): Object;
getElementsSlim(): Object;
getElementsString(): string;
loadElementsFrom(source: Object): Raska;
toggleFullScreen(): Raska;
positionTypes(): any;
onCanvasInteraction(type: string, trigger: (x: number, y: number, details: raskaEventDetail) => {}): Raska;
checkCollisionOn(x: number, y: number): boolean;
tryGetElementOn(x: number, y: number): raskaNode;
remove(node: raskaNode): Raska;
getCanvasBoundaries(): { maxH: number; maxW: number };
clear(): Raska;
animation: raskaAnimation;
}
declare var raska: Raska;