@argila/core 0.0.0-alpha-20250607064138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/Argila.d.ts +24 -0
- package/dist/Argila.d.ts.map +1 -0
- package/dist/Argila.js +62 -0
- package/dist/Argila.test.d.ts +2 -0
- package/dist/Argila.test.d.ts.map +1 -0
- package/dist/Argila.test.js +150 -0
- package/dist/Canvas.d.ts +117 -0
- package/dist/Canvas.d.ts.map +1 -0
- package/dist/Canvas.js +311 -0
- package/dist/Canvas.test.d.ts +2 -0
- package/dist/Canvas.test.d.ts.map +1 -0
- package/dist/Canvas.test.js +311 -0
- package/dist/Common.d.ts +11 -0
- package/dist/Common.d.ts.map +1 -0
- package/dist/Common.js +64 -0
- package/dist/Common.test.js +118 -0
- package/dist/Event.d.ts +10 -0
- package/dist/Event.d.ts.map +1 -0
- package/dist/Event.js +23 -0
- package/dist/Event.test.js +72 -0
- package/dist/LinkedList.d.ts +44 -0
- package/dist/LinkedList.d.ts.map +1 -0
- package/dist/LinkedList.js +95 -0
- package/dist/LinkedList.test.d.ts +2 -0
- package/dist/LinkedList.test.d.ts.map +1 -0
- package/dist/LinkedList.test.js +197 -0
- package/dist/Vector3.d.ts +104 -0
- package/dist/Vector3.d.ts.map +1 -0
- package/dist/Vector3.js +185 -0
- package/dist/Vector3.test.d.ts +2 -0
- package/dist/Vector3.test.d.ts.map +1 -0
- package/dist/Vector3.test.js +127 -0
- package/dist/common.test.d.ts +2 -0
- package/dist/common.test.d.ts.map +1 -0
- package/dist/event.test.d.ts +2 -0
- package/dist/event.test.d.ts.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/systems/Draw.d.ts +8 -0
- package/dist/systems/Draw.d.ts.map +1 -0
- package/dist/systems/Draw.js +15 -0
- package/dist/systems/Entity.d.ts +18 -0
- package/dist/systems/Entity.d.ts.map +1 -0
- package/dist/systems/Entity.js +44 -0
- package/dist/systems/Input.d.ts +127 -0
- package/dist/systems/Input.d.ts.map +1 -0
- package/dist/systems/Input.js +191 -0
- package/dist/systems/Loop.d.ts +29 -0
- package/dist/systems/Loop.d.ts.map +1 -0
- package/dist/systems/Loop.js +93 -0
- package/dist/systems/Render.d.ts +21 -0
- package/dist/systems/Render.d.ts.map +1 -0
- package/dist/systems/Render.js +112 -0
- package/dist/systems/Shape.d.ts +48 -0
- package/dist/systems/Shape.d.ts.map +1 -0
- package/dist/systems/Shape.js +146 -0
- package/dist/systems/System.d.ts +22 -0
- package/dist/systems/System.d.ts.map +1 -0
- package/dist/systems/System.js +20 -0
- package/dist/systems/World.d.ts +24 -0
- package/dist/systems/World.d.ts.map +1 -0
- package/dist/systems/World.js +84 -0
- package/dist/systems/debugs/Debug.d.ts +9 -0
- package/dist/systems/debugs/Debug.d.ts.map +1 -0
- package/dist/systems/debugs/Debug.js +12 -0
- package/dist/systems/debugs/InputDebug.d.ts +7 -0
- package/dist/systems/debugs/InputDebug.d.ts.map +1 -0
- package/dist/systems/debugs/InputDebug.js +11 -0
- package/dist/systems/debugs/LoopDebug.d.ts +7 -0
- package/dist/systems/debugs/LoopDebug.d.ts.map +1 -0
- package/dist/systems/debugs/LoopDebug.js +11 -0
- package/package.json +79 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Eduardo Lopes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/Argila.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CreateCanvasConfig } from "./Canvas";
|
|
2
|
+
import Event from "./Event";
|
|
3
|
+
export interface IArgilaConfig {
|
|
4
|
+
container: string | HTMLElement;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
createCanvas?: boolean;
|
|
7
|
+
canvasList?: CreateCanvasConfig[];
|
|
8
|
+
}
|
|
9
|
+
export default class Argila {
|
|
10
|
+
tickFunc: string;
|
|
11
|
+
rAFid: number | undefined;
|
|
12
|
+
dt: number | undefined;
|
|
13
|
+
last: number | undefined;
|
|
14
|
+
now: number | undefined;
|
|
15
|
+
time: number | undefined;
|
|
16
|
+
debug: boolean;
|
|
17
|
+
container: string | HTMLElement;
|
|
18
|
+
beforeTickEvent: Event<number>;
|
|
19
|
+
afterTickEvent: Event<number>;
|
|
20
|
+
constructor(options: IArgilaConfig);
|
|
21
|
+
tick(dt: number): void;
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=Argila.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Argila.d.ts","sourceRoot":"","sources":["../src/Argila.ts"],"names":[],"mappings":"AAEA,OAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKtD,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAC;CACnC;AACD,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,GAAG,WAAW,CAAC;IAEhC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC/B,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAElB,OAAO,EAAE,aAAa;IAkClC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAWtB,OAAO,IAAI,IAAI;CAUhB"}
|
package/dist/Argila.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import Entity from "./systems/Entity";
|
|
3
|
+
import Canvas from "./Canvas";
|
|
4
|
+
import World from "./systems/World";
|
|
5
|
+
import Shape from "./systems/Shape";
|
|
6
|
+
import Vector3 from "./Vector3";
|
|
7
|
+
import Loop from "./systems/Loop";
|
|
8
|
+
import Event from "./Event";
|
|
9
|
+
export default class Argila {
|
|
10
|
+
tickFunc;
|
|
11
|
+
rAFid;
|
|
12
|
+
dt;
|
|
13
|
+
last;
|
|
14
|
+
now;
|
|
15
|
+
time;
|
|
16
|
+
debug;
|
|
17
|
+
container;
|
|
18
|
+
beforeTickEvent;
|
|
19
|
+
afterTickEvent;
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.debug = options.debug ?? false;
|
|
22
|
+
this.container = options.container;
|
|
23
|
+
if (options.canvasList && options.canvasList?.length > 0) {
|
|
24
|
+
options.canvasList.forEach((canvas) => {
|
|
25
|
+
Canvas.create({
|
|
26
|
+
...canvas
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
this.beforeTickEvent = new Event("before-tick");
|
|
31
|
+
this.afterTickEvent = new Event("after-tick");
|
|
32
|
+
if ((!options.canvasList || options.canvasList.length === 0) && options.createCanvas) {
|
|
33
|
+
const mainCanvas = Canvas.create({
|
|
34
|
+
id: "main",
|
|
35
|
+
width: 800,
|
|
36
|
+
height: 800,
|
|
37
|
+
autoWidth: true,
|
|
38
|
+
autoHeight: true
|
|
39
|
+
});
|
|
40
|
+
Canvas.append(mainCanvas.id, options.container);
|
|
41
|
+
}
|
|
42
|
+
this.tickFunc = Loop.create("main", this.tick.bind(this));
|
|
43
|
+
}
|
|
44
|
+
tick(dt) {
|
|
45
|
+
Canvas.clear();
|
|
46
|
+
this.beforeTickEvent.fire(dt);
|
|
47
|
+
World.forEach((world) => {
|
|
48
|
+
World.tick(dt, world);
|
|
49
|
+
});
|
|
50
|
+
this.afterTickEvent.fire(dt);
|
|
51
|
+
}
|
|
52
|
+
destroy() {
|
|
53
|
+
Loop.clear();
|
|
54
|
+
this.beforeTickEvent.destroy();
|
|
55
|
+
this.afterTickEvent.destroy();
|
|
56
|
+
Entity.clear();
|
|
57
|
+
World.clear();
|
|
58
|
+
Shape.clear();
|
|
59
|
+
Vector3.clear();
|
|
60
|
+
Canvas.destroyAll();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Argila.test.d.ts","sourceRoot":"","sources":["../src/Argila.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
3
|
+
import Argila from "./Argila";
|
|
4
|
+
import Canvas from "./Canvas";
|
|
5
|
+
import Loop from "./systems/Loop";
|
|
6
|
+
import Event from "./Event";
|
|
7
|
+
import Entity from "./systems/Entity";
|
|
8
|
+
import World from "./systems/World";
|
|
9
|
+
import Shape from "./systems/Shape";
|
|
10
|
+
import Vector3 from "./Vector3";
|
|
11
|
+
describe("Argila", () => {
|
|
12
|
+
let argila;
|
|
13
|
+
let config;
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
config = {
|
|
16
|
+
container: "test-container",
|
|
17
|
+
debug: true,
|
|
18
|
+
createCanvas: true,
|
|
19
|
+
canvasList: [
|
|
20
|
+
{
|
|
21
|
+
id: "test-canvas",
|
|
22
|
+
width: 500,
|
|
23
|
+
height: 500,
|
|
24
|
+
autoWidth: false,
|
|
25
|
+
autoHeight: false
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
argila = new Argila(config);
|
|
30
|
+
});
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
argila.destroy();
|
|
33
|
+
});
|
|
34
|
+
it("should initialize with the correct configuration", () => {
|
|
35
|
+
expect(argila.debug).toBe(true);
|
|
36
|
+
expect(argila.container).toBe("test-container");
|
|
37
|
+
expect(argila.beforeTickEvent).toBeInstanceOf(Event);
|
|
38
|
+
expect(argila.afterTickEvent).toBeInstanceOf(Event);
|
|
39
|
+
});
|
|
40
|
+
it("should create canvases based on the configuration", () => {
|
|
41
|
+
expect(Canvas.get("test-canvas")).toBeDefined();
|
|
42
|
+
expect(Canvas.get("main")).toBeUndefined();
|
|
43
|
+
});
|
|
44
|
+
it("should create the main canvas if canvasList is empty and createCanvas is true", () => {
|
|
45
|
+
config.canvasList = [];
|
|
46
|
+
config.createCanvas = true;
|
|
47
|
+
argila = new Argila(config);
|
|
48
|
+
expect(Canvas.get("main")).toBeDefined();
|
|
49
|
+
});
|
|
50
|
+
it("should not create the main canvas if canvasList is not empty", () => {
|
|
51
|
+
expect(Canvas.get("main")).toBeUndefined();
|
|
52
|
+
});
|
|
53
|
+
it("should not create the main canvas if createCanvas is false", () => {
|
|
54
|
+
config.createCanvas = false;
|
|
55
|
+
config.canvasList = [];
|
|
56
|
+
argila = new Argila(config);
|
|
57
|
+
expect(Canvas.get("main")).toBeUndefined();
|
|
58
|
+
});
|
|
59
|
+
it("should initialize with default debug value as false", () => {
|
|
60
|
+
config.debug = void 0;
|
|
61
|
+
argila = new Argila({
|
|
62
|
+
...config,
|
|
63
|
+
canvasList: [
|
|
64
|
+
{
|
|
65
|
+
id: "test-canvas-2",
|
|
66
|
+
width: 500,
|
|
67
|
+
height: 500,
|
|
68
|
+
autoWidth: false,
|
|
69
|
+
autoHeight: false
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
expect(argila.debug).toBe(false);
|
|
74
|
+
});
|
|
75
|
+
it("should append the main canvas to the container if created", () => {
|
|
76
|
+
config.canvasList = [];
|
|
77
|
+
config.createCanvas = true;
|
|
78
|
+
argila = new Argila(config);
|
|
79
|
+
const mainCanvas = Canvas.get("main");
|
|
80
|
+
expect(mainCanvas).toBeDefined();
|
|
81
|
+
expect(mainCanvas?.element.parentElement).toBeDefined();
|
|
82
|
+
});
|
|
83
|
+
it("should call tick function and fire events", () => {
|
|
84
|
+
const beforeTickSpy = vi.spyOn(argila.beforeTickEvent, "fire");
|
|
85
|
+
const afterTickSpy = vi.spyOn(argila.afterTickEvent, "fire");
|
|
86
|
+
argila.tick(16);
|
|
87
|
+
expect(beforeTickSpy).toHaveBeenCalledWith(16);
|
|
88
|
+
expect(afterTickSpy).toHaveBeenCalledWith(16);
|
|
89
|
+
});
|
|
90
|
+
it("should call tick function and fire events for multiple worlds", () => {
|
|
91
|
+
const beforeTickSpy = vi.spyOn(argila.beforeTickEvent, "fire");
|
|
92
|
+
const afterTickSpy = vi.spyOn(argila.afterTickEvent, "fire");
|
|
93
|
+
const world1 = { id: "world1" };
|
|
94
|
+
const world2 = { id: "world2" };
|
|
95
|
+
vi.spyOn(World, "forEach").mockImplementation((callback) => {
|
|
96
|
+
callback(world1.id);
|
|
97
|
+
callback(world2.id);
|
|
98
|
+
});
|
|
99
|
+
const worldTickSpy = vi.spyOn(World, "tick");
|
|
100
|
+
argila.tick(16);
|
|
101
|
+
expect(beforeTickSpy).toHaveBeenCalledWith(16);
|
|
102
|
+
expect(afterTickSpy).toHaveBeenCalledWith(16);
|
|
103
|
+
expect(worldTickSpy).toHaveBeenCalledTimes(2);
|
|
104
|
+
expect(worldTickSpy).toHaveBeenCalledWith(16, world1.id);
|
|
105
|
+
expect(worldTickSpy).toHaveBeenCalledWith(16, world2.id);
|
|
106
|
+
});
|
|
107
|
+
it("should destroy all systems and clear resources", () => {
|
|
108
|
+
const loopClearSpy = vi.spyOn(Loop, "clear");
|
|
109
|
+
const entityClearSpy = vi.spyOn(Entity, "clear");
|
|
110
|
+
const worldClearSpy = vi.spyOn(World, "clear");
|
|
111
|
+
const shapeClearSpy = vi.spyOn(Shape, "clear");
|
|
112
|
+
const vector3ClearSpy = vi.spyOn(Vector3, "clear");
|
|
113
|
+
const canvasDestroyAllSpy = vi.spyOn(Canvas, "destroyAll");
|
|
114
|
+
argila.destroy();
|
|
115
|
+
expect(loopClearSpy).toHaveBeenCalled();
|
|
116
|
+
expect(entityClearSpy).toHaveBeenCalled();
|
|
117
|
+
expect(worldClearSpy).toHaveBeenCalled();
|
|
118
|
+
expect(shapeClearSpy).toHaveBeenCalled();
|
|
119
|
+
expect(vector3ClearSpy).toHaveBeenCalled();
|
|
120
|
+
expect(canvasDestroyAllSpy).toHaveBeenCalled();
|
|
121
|
+
});
|
|
122
|
+
it("should call tick function multiple times and fire events each time", () => {
|
|
123
|
+
const beforeTickSpy = vi.spyOn(argila.beforeTickEvent, "fire");
|
|
124
|
+
const afterTickSpy = vi.spyOn(argila.afterTickEvent, "fire");
|
|
125
|
+
argila.tick(16);
|
|
126
|
+
argila.tick(32);
|
|
127
|
+
expect(beforeTickSpy).toHaveBeenCalledTimes(2);
|
|
128
|
+
expect(afterTickSpy).toHaveBeenCalledTimes(2);
|
|
129
|
+
expect(beforeTickSpy).toHaveBeenCalledWith(16);
|
|
130
|
+
expect(afterTickSpy).toHaveBeenCalledWith(16);
|
|
131
|
+
expect(beforeTickSpy).toHaveBeenCalledWith(32);
|
|
132
|
+
expect(afterTickSpy).toHaveBeenCalledWith(32);
|
|
133
|
+
});
|
|
134
|
+
it("should handle destroy being called multiple times gracefully", () => {
|
|
135
|
+
const loopClearSpy = vi.spyOn(Loop, "clear");
|
|
136
|
+
const entityClearSpy = vi.spyOn(Entity, "clear");
|
|
137
|
+
const worldClearSpy = vi.spyOn(World, "clear");
|
|
138
|
+
const shapeClearSpy = vi.spyOn(Shape, "clear");
|
|
139
|
+
const vector3ClearSpy = vi.spyOn(Vector3, "clear");
|
|
140
|
+
const canvasDestroyAllSpy = vi.spyOn(Canvas, "destroyAll");
|
|
141
|
+
argila.destroy();
|
|
142
|
+
argila.destroy();
|
|
143
|
+
expect(loopClearSpy).toHaveBeenCalledTimes(2);
|
|
144
|
+
expect(entityClearSpy).toHaveBeenCalledTimes(2);
|
|
145
|
+
expect(worldClearSpy).toHaveBeenCalledTimes(2);
|
|
146
|
+
expect(shapeClearSpy).toHaveBeenCalledTimes(2);
|
|
147
|
+
expect(vector3ClearSpy).toHaveBeenCalledTimes(2);
|
|
148
|
+
expect(canvasDestroyAllSpy).toHaveBeenCalledTimes(2);
|
|
149
|
+
});
|
|
150
|
+
});
|
package/dist/Canvas.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { SetOptional } from "type-fest";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration interface for Canvas objects
|
|
4
|
+
*/
|
|
5
|
+
export interface CanvasConfig {
|
|
6
|
+
element: HTMLCanvasElement;
|
|
7
|
+
ctx: CanvasRenderingContext2D;
|
|
8
|
+
id: string;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
autoWidth: boolean;
|
|
12
|
+
autoHeight: boolean;
|
|
13
|
+
dpr: number;
|
|
14
|
+
lastWidth: number;
|
|
15
|
+
lastHeight: number;
|
|
16
|
+
clear: boolean;
|
|
17
|
+
clearColor: string;
|
|
18
|
+
windowResizeCallback: () => void;
|
|
19
|
+
onResize?: () => void;
|
|
20
|
+
contextLostCallback?: (event: Event) => void;
|
|
21
|
+
contextRestoredCallback?: (event: Event) => void;
|
|
22
|
+
isVisible?: boolean;
|
|
23
|
+
}
|
|
24
|
+
type InternalCanvasConfigProps = "ctx" | "dpr" | "resizeCallback" | "lastWidth" | "lastHeight" | "windowResizeCallback";
|
|
25
|
+
type OptionalCanvasConfigProps = "clear" | "clearColor" | "width" | "height" | "autoWidth" | "autoHeight" | "element";
|
|
26
|
+
export type CreateCanvasConfig = SetOptional<Omit<CanvasConfig, InternalCanvasConfigProps>, OptionalCanvasConfigProps>;
|
|
27
|
+
/**
|
|
28
|
+
* Canvas utility class for managing HTML5 canvases
|
|
29
|
+
*/
|
|
30
|
+
export default class Canvas {
|
|
31
|
+
static id: string;
|
|
32
|
+
static list: Map<string, CanvasConfig>;
|
|
33
|
+
private static resizeObserver;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new canvas configuration
|
|
36
|
+
* @param options Canvas configuration options
|
|
37
|
+
* @returns The created canvas configuration
|
|
38
|
+
* @throws Error if a canvas with the same ID already exists
|
|
39
|
+
*/
|
|
40
|
+
static create(options: CreateCanvasConfig): CanvasConfig;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves a canvas configuration by its ID
|
|
43
|
+
* @param id The canvas ID
|
|
44
|
+
* @returns The canvas configuration or undefined if not found
|
|
45
|
+
*/
|
|
46
|
+
static get(id: string): CanvasConfig | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Updates canvas properties
|
|
49
|
+
* @param id The canvas ID
|
|
50
|
+
* @param options Options to update
|
|
51
|
+
*/
|
|
52
|
+
static set(id: string, options: Partial<Omit<CanvasConfig, "ctx" | "element" | "dpr">>): void;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the clear color for a canvas
|
|
55
|
+
* @param id The canvas ID
|
|
56
|
+
* @param clearColor The color to set
|
|
57
|
+
*/
|
|
58
|
+
static setClearColor(id: string, clearColor: string): void;
|
|
59
|
+
/**
|
|
60
|
+
* Executes a callback for each canvas
|
|
61
|
+
* @param callback Function to execute for each canvas
|
|
62
|
+
*/
|
|
63
|
+
static forEach(callback: (canvas: CanvasConfig) => void): void;
|
|
64
|
+
/**
|
|
65
|
+
* Automatically resizes a canvas based on its parent element or window
|
|
66
|
+
* @param id The canvas ID
|
|
67
|
+
*/
|
|
68
|
+
static autoResize(id: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* Appends a canvas to a container
|
|
71
|
+
* @param id The canvas ID
|
|
72
|
+
* @param containerId The container ID or element
|
|
73
|
+
*/
|
|
74
|
+
static append(id: string, containerId: string | HTMLElement): void;
|
|
75
|
+
/**
|
|
76
|
+
* Fixes the device pixel ratio for a canvas
|
|
77
|
+
* @param id The canvas ID
|
|
78
|
+
*/
|
|
79
|
+
static fixDPI(id: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Handles canvas resize events
|
|
82
|
+
* @param id The canvas ID
|
|
83
|
+
*/
|
|
84
|
+
static onResize(id: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* Destroys a canvas
|
|
87
|
+
* @param id The canvas ID
|
|
88
|
+
*/
|
|
89
|
+
static destroy(id: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* Clears all canvases
|
|
92
|
+
*/
|
|
93
|
+
static clear(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Destroys all canvases
|
|
96
|
+
*/
|
|
97
|
+
static destroyAll(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Checks if a canvas is visible in the viewport
|
|
100
|
+
* @param id The canvas ID
|
|
101
|
+
* @returns True if the canvas is visible
|
|
102
|
+
*/
|
|
103
|
+
static isVisible(id: string): boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Updates visibility status for all canvases
|
|
106
|
+
*/
|
|
107
|
+
static updateVisibility(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Resizes a canvas to specific dimensions
|
|
110
|
+
* @param id The canvas ID
|
|
111
|
+
* @param width New width
|
|
112
|
+
* @param height New height
|
|
113
|
+
*/
|
|
114
|
+
static resize(id: string, width: number, height: number): void;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=Canvas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Canvas.d.ts","sourceRoot":"","sources":["../src/Canvas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAI7C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,GAAG,EAAE,wBAAwB,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7C,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjD,SAAS,CA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