This repository has been archived by the owner on Oct 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yace.d.ts
194 lines (194 loc) · 6.7 KB
/
yace.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/// <reference path="typings/index.d.ts" />
declare module "core/interfaces/LifeCycle" {
interface LifeCycle {
onUpdate(): void;
}
export default LifeCycle;
}
declare module "core/YaceContainer" {
import YaceObject from "core/YaceObject";
import LifeCycle from "core/interfaces/LifeCycle";
abstract class YaceContainer implements LifeCycle {
childs: YaceObject[];
add(obj: YaceObject): YaceContainer;
remove(obj: YaceObject): YaceContainer;
onUpdate(): void;
}
export default YaceContainer;
}
declare module "utils/Point2D" {
export default class Point2D {
static ONE: Point2D;
static ZERO: Point2D;
x: number;
y: number;
constructor(x: number, y: number);
static concat(v1: Point2D, v2: Point2D): Point2D;
static subtract(v1: Point2D, v2: Point2D): Point2D;
static multiply(v1: Point2D, v2: Point2D): Point2D;
static divide(v1: Point2D, v2: Point2D): Point2D;
static max(v1: Point2D, v2: Point2D): Point2D;
static min(v1: Point2D, v2: Point2D): Point2D;
static invert(v1: Point2D): Point2D;
static equals(v1: Point2D, v2: Point2D): boolean;
}
}
declare module "utils/Box2D" {
import Point2D from "utils/Point2D";
export default class Box2D {
min: Point2D;
max: Point2D;
constructor(min: Point2D, max: Point2D);
width(): number;
height(): number;
static bound(bounds: Box2D, point: Point2D): Point2D;
}
}
declare module "core/interfaces/Boxed" {
import Box2D from "utils/Box2D";
interface Boxed {
box(): Box2D;
}
export default Boxed;
}
declare module "core/YaceCamera" {
import YaceObject from "core/YaceObject";
import YaceScene from "core/YaceScene";
import Point2D from "utils/Point2D";
import Boxed from "core/interfaces/Boxed";
import Box2D from "utils/Box2D";
export default class YaceCamera extends YaceObject implements Boxed {
private canvas;
private context;
backgroundColor: string | CanvasGradient | CanvasPattern;
dragSpeed: Point2D;
zoomSpeed: Point2D;
private mousePoint;
private cameraPoint;
constructor(canvas: JQuery);
draw(scene: YaceScene, context: CanvasRenderingContext2D): boolean;
box(): Box2D;
private dragStart(event);
private dragEnd();
private dragEvent(event);
private zoomEvent(event);
}
}
declare module "core/YaceScene" {
import YaceContainer from "core/YaceContainer";
import YaceCamera from "core/YaceCamera";
export default class YaceScene extends YaceContainer {
canvas: HTMLCanvasElement;
context: CanvasRenderingContext2D;
cameras: YaceCamera[];
constructor(width: number, height: number);
onUpdate(): void;
addCamera(camera: YaceCamera): void;
removeCamera(camera: YaceCamera): void;
}
}
declare module "core/interfaces/Drawable" {
import YaceScene from "core/YaceScene";
interface Drawable {
draw(scene: YaceScene, context: CanvasRenderingContext2D): boolean;
isDirty(): boolean;
}
export default Drawable;
}
declare module "core/YaceObject" {
import YaceContainer from "core/YaceContainer";
import YaceBehavior from "core/YaceBehavior";
import Drawable from "core/interfaces/Drawable";
import Point2D from "utils/Point2D";
import YaceScene from "core/YaceScene";
export default class YaceObject extends YaceContainer implements Drawable {
behaviors: YaceBehavior[];
position: Point2D;
scale: Point2D;
dirty: boolean;
addBehavior(behavior: YaceBehavior): YaceObject;
removeBehavior(behavior: YaceBehavior): YaceObject;
onUpdate(): void;
draw(scene: YaceScene, context: CanvasRenderingContext2D): boolean;
isDirty(): boolean;
}
}
declare module "core/YaceBehavior" {
import YaceObject from "core/YaceObject";
import LifeCycle from "core/interfaces/LifeCycle";
abstract class YaceBehavior implements LifeCycle {
object: YaceObject;
onUpdate(): void;
}
export default YaceBehavior;
}
declare module "behaviors/BoundsBehavior" {
import YaceBehavior from "core/YaceBehavior";
import Box2D from "utils/Box2D";
export default class BoundsBehavior extends YaceBehavior {
positionBound: Box2D;
scaleBound: Box2D;
boxBound: Box2D;
boxFixRatio: boolean;
onUpdate(): void;
}
}
declare module "renders/ImageRenderer" {
import YaceBehavior from "core/YaceBehavior";
import Drawable from "core/interfaces/Drawable";
import YaceScene from "core/YaceScene";
export default class ImageRenderer extends YaceBehavior implements Drawable {
image: HTMLImageElement;
dirty: boolean;
constructor(image: HTMLImageElement);
draw(scene: YaceScene, context: CanvasRenderingContext2D): boolean;
isDirty(): boolean;
}
}
declare module "renders/PolyRenderer" {
import YaceBehavior from "core/YaceBehavior";
import Drawable from "core/interfaces/Drawable";
import YaceScene from "core/YaceScene";
import Point2D from "utils/Point2D";
export default class PolyRenderer extends YaceBehavior implements Drawable {
dirty: boolean;
points: Point2D[];
fillColor: string | CanvasGradient | CanvasPattern;
strokeColor: string | CanvasGradient | CanvasPattern;
strokeSize: number;
constructor(points: Point2D[]);
draw(scene: YaceScene, context: CanvasRenderingContext2D): boolean;
isDirty(): boolean;
}
}
declare module "utils/TileSet" {
import Point2D from "utils/Point2D";
import Box2D from "utils/Box2D";
export default class TileSet {
image: HTMLImageElement;
tiles: Box2D[];
constructor(image: HTMLImageElement);
tile(idx: number): Box2D;
static simpleGrid(image: HTMLImageElement, grid: Point2D): TileSet;
}
}
declare module "renders/TileRenderer" {
import YaceBehavior from "core/YaceBehavior";
import Drawable from "core/interfaces/Drawable";
import YaceScene from "core/YaceScene";
import TileSet from "utils/TileSet";
export default class TileRenderer extends YaceBehavior implements Drawable {
tileSet: TileSet;
dirty: boolean;
active: number;
constructor(tileSet: TileSet);
activate(active: number): void;
draw(scene: YaceScene, context: CanvasRenderingContext2D): boolean;
isDirty(): boolean;
}
}
declare module "utils/ImageUtils" {
export default class ImageUtils {
static load(url: string, callback: (HTMLImageElement) => void): void;
}
}