88 lines
2.1 KiB
TypeScript
88 lines
2.1 KiB
TypeScript
declare module "matter-js" {
|
|
namespace Matter {
|
|
type Engine = any;
|
|
type Render = {
|
|
canvas: HTMLCanvasElement;
|
|
context: CanvasRenderingContext2D;
|
|
options: Record<string, any>;
|
|
mouse?: Mouse;
|
|
[key: string]: any;
|
|
};
|
|
type MouseConstraint = any;
|
|
type Body = any;
|
|
type Composite = any;
|
|
type Constraint = any;
|
|
type Mouse = any;
|
|
type Runner = any;
|
|
|
|
interface IBodyDefinition {
|
|
[key: string]: any;
|
|
}
|
|
}
|
|
|
|
const Matter: {
|
|
Engine: {
|
|
create(options?: Record<string, any>): Matter.Engine;
|
|
clear(engine: Matter.Engine): void;
|
|
run(engine: Matter.Engine): void;
|
|
};
|
|
Render: {
|
|
create(options: Record<string, any>): Matter.Render;
|
|
run(render: Matter.Render): void;
|
|
stop(render: Matter.Render): void;
|
|
};
|
|
Runner: {
|
|
create(options?: Record<string, any>): Matter.Runner;
|
|
run(runner: Matter.Runner, engine: Matter.Engine): void;
|
|
stop(runner: Matter.Runner): void;
|
|
};
|
|
Bodies: {
|
|
rectangle(
|
|
x: number,
|
|
y: number,
|
|
width: number,
|
|
height: number,
|
|
options?: Matter.IBodyDefinition
|
|
): Matter.Body;
|
|
circle(
|
|
x: number,
|
|
y: number,
|
|
radius: number,
|
|
options?: Matter.IBodyDefinition
|
|
): Matter.Body;
|
|
};
|
|
Body: Record<string, (...args: any[]) => any>;
|
|
Composite: {
|
|
add(composite: any, bodies: any): void;
|
|
remove(composite: any, bodies: any): void;
|
|
};
|
|
Composites: Record<string, (...args: any[]) => any>;
|
|
Constraint: {
|
|
create(options?: Record<string, any>): Matter.Constraint;
|
|
};
|
|
Mouse: {
|
|
create(element: HTMLElement | HTMLCanvasElement): Matter.Mouse;
|
|
};
|
|
MouseConstraint: {
|
|
create(
|
|
engine: Matter.Engine,
|
|
options?: Record<string, any>
|
|
): Matter.MouseConstraint;
|
|
};
|
|
Events: {
|
|
on(
|
|
target: any,
|
|
eventName: string,
|
|
callback: (...args: any[]) => void
|
|
): void;
|
|
off(
|
|
target: any,
|
|
eventName: string,
|
|
callback?: (...args: any[]) => void
|
|
): void;
|
|
};
|
|
};
|
|
|
|
export default Matter;
|
|
}
|