@oliversalzburg/js-utils 0.0.15 → 0.0.16
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/_site/assets/highlight.css +92 -8
- package/_site/assets/navigation.js +1 -1
- package/_site/assets/search.js +1 -1
- package/_site/classes/AbstractError.html +8 -8
- package/_site/classes/Canvas.html +36 -25
- package/_site/classes/CanvasSandbox.html +36 -21
- package/_site/classes/Euler.html +44 -44
- package/_site/classes/InternalError.html +9 -9
- package/_site/classes/InvalidArgumentError.html +8 -8
- package/_site/classes/InvalidOperationError.html +8 -8
- package/_site/classes/Matrix3.html +41 -41
- package/_site/classes/NotImplementedError.html +8 -8
- package/_site/classes/PermissionViolationError.html +8 -8
- package/_site/classes/Quaternion.html +46 -46
- package/_site/classes/Random.html +17 -17
- package/_site/classes/RenderLoop.html +21 -21
- package/_site/classes/ResourceConflictError.html +8 -8
- package/_site/classes/Transformation.html +8 -8
- package/_site/classes/UnexpectedNilError.html +6 -6
- package/_site/classes/UnknownError.html +8 -8
- package/_site/classes/Vector2.html +33 -33
- package/_site/classes/Vector3.html +43 -43
- package/_site/classes/Vector4.html +33 -33
- package/_site/functions/addVector2.html +4 -4
- package/_site/functions/addVector3.html +4 -4
- package/_site/functions/blend.html +4 -4
- package/_site/functions/blendAdditive.html +4 -4
- package/_site/functions/blendSubtractive.html +4 -4
- package/_site/functions/clamp.html +4 -4
- package/_site/functions/coalesceOnRejection.html +8 -5
- package/_site/functions/cosDeg.html +4 -4
- package/_site/functions/crossVector3.html +4 -4
- package/_site/functions/deg2rad.html +4 -4
- package/_site/functions/difference.html +4 -4
- package/_site/functions/distance.html +4 -4
- package/_site/functions/dotVector3.html +4 -4
- package/_site/functions/errorToJSON.html +4 -4
- package/_site/functions/errorToRecord.html +4 -4
- package/_site/functions/errorToSimpleSerializable.html +4 -4
- package/_site/functions/filterType.html +4 -4
- package/_site/functions/formatString.html +5 -5
- package/_site/functions/formatStringTemplate.html +5 -5
- package/_site/functions/fromRGB.html +4 -4
- package/_site/functions/fromRGBA.html +4 -4
- package/_site/functions/getA.html +4 -4
- package/_site/functions/getB.html +4 -4
- package/_site/functions/getDocumentElementTypeById.html +6 -8
- package/_site/functions/getDocumentElementTypeByIdStrict.html +48 -0
- package/_site/functions/getG.html +4 -4
- package/_site/functions/getR.html +4 -4
- package/_site/functions/intersect.html +4 -4
- package/_site/functions/is.html +4 -4
- package/_site/functions/isError.html +4 -4
- package/_site/functions/isInteger.html +4 -4
- package/_site/functions/isNil.html +4 -4
- package/_site/functions/isqrt.html +4 -4
- package/_site/functions/multiplyVector2.html +4 -4
- package/_site/functions/multiplyVector3.html +4 -4
- package/_site/functions/mustExist.html +4 -4
- package/_site/functions/nextPalette.html +4 -4
- package/_site/functions/prepareAsyncContext.html +4 -4
- package/_site/functions/putPixel32.html +4 -4
- package/_site/functions/putPixel32Add.html +4 -4
- package/_site/functions/putPixel32Sub.html +4 -4
- package/_site/functions/putSubPixel32.html +4 -4
- package/_site/functions/rad2deg.html +4 -4
- package/_site/functions/randomRange.html +4 -4
- package/_site/functions/safeRGBComponent.html +4 -4
- package/_site/functions/seedFromString.html +4 -4
- package/_site/functions/shuffleArray.html +4 -4
- package/_site/functions/sinDeg.html +4 -4
- package/_site/functions/sleep.html +4 -4
- package/_site/functions/somecolor.html +4 -4
- package/_site/functions/subtractVector2.html +4 -4
- package/_site/functions/subtractVector3.html +4 -4
- package/_site/functions/toGrayScale.html +4 -4
- package/_site/functions/unknownToError.html +4 -4
- package/_site/index.html +4 -4
- package/_site/interfaces/CanvasOptions.html +5 -5
- package/_site/interfaces/CanvasSandboxApplication.html +10 -10
- package/_site/interfaces/CanvasSandboxExpectedOptions.html +6 -6
- package/_site/interfaces/CanvasSandboxOptions.html +45 -0
- package/_site/interfaces/RenderLoopOptions.html +6 -6
- package/_site/modules.html +7 -4
- package/_site/types/AnyAsyncFunction.html +4 -4
- package/_site/types/AnyConstructor.html +4 -4
- package/_site/types/AnyFunction.html +4 -4
- package/_site/types/ConstructorOf.html +4 -4
- package/_site/types/FunctionReturning.html +4 -4
- package/_site/types/Maybe.html +4 -4
- package/_site/types/Mixin.html +4 -4
- package/_site/types/Nil.html +4 -4
- package/_site/types/RenderLoopCallback.html +4 -4
- package/_site/types/SerializedError.html +4 -4
- package/_site/variables/CANVAS_SANDBOX_DEFAULT_CSS.html +41 -0
- package/_site/variables/MS_PER_FRAME_60FPS.html +4 -4
- package/_site/variables/PALETTES.html +4 -4
- package/_site/variables/TWO_PI.html +4 -4
- package/_site/variables/random-1.html +4 -4
- package/lib/async.d.ts +6 -3
- package/lib/async.js +8 -2
- package/lib/async.js.map +1 -1
- package/lib/dom/core.d.ts +13 -3
- package/lib/dom/core.js +22 -3
- package/lib/dom/core.js.map +1 -1
- package/lib/graphics/canvas-sandbox.d.ts +40 -39
- package/lib/graphics/canvas-sandbox.js +87 -44
- package/lib/graphics/canvas-sandbox.js.map +1 -1
- package/lib/graphics/canvas.js +0 -1
- package/lib/graphics/canvas.js.map +1 -1
- package/lib/graphics/render-loop.d.ts +1 -1
- package/lib/graphics/render-loop.js +51 -33
- package/lib/graphics/render-loop.js.map +1 -1
- package/package.json +3 -3
- package/_site/favicon.ico +0 -0
- package/lib/Async.d.ts +0 -3
- package/lib/Async.js +0 -17
- package/lib/Async.js.map +0 -1
- package/lib/graphics/canvas copy.d.ts +0 -170
- package/lib/graphics/canvas copy.js +0 -300
- package/lib/graphics/canvas copy.js.map +0 -1
- package/lib/graphics/canvas-worker.d.ts +0 -50
- package/lib/graphics/canvas-worker.js +0 -78
- package/lib/graphics/canvas-worker.js.map +0 -1
- package/lib/math/vector.d.ts +0 -2
- package/lib/math/vector.js +0 -3
- package/lib/math/vector.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas.js","sourceRoot":"","sources":["../../source/graphics/canvas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AA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GAAG,QAAQ,GAAG,KAAK,CAAC;IAC3C,MAAM,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC1C,MAAM,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC;IAC1C,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;IAEzC,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAChD,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC,CAAC"}
|
|
@@ -51,7 +51,7 @@ export declare class RenderLoop {
|
|
|
51
51
|
/**
|
|
52
52
|
* The time at which we rendered the last frame to the DOM.
|
|
53
53
|
*/
|
|
54
|
-
private
|
|
54
|
+
private previousTimestampPresent;
|
|
55
55
|
/**
|
|
56
56
|
* The ID of our {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame requestAnimationFrame} request.
|
|
57
57
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { blend } from "./core.js";
|
|
1
2
|
/**
|
|
2
3
|
* The amount of milliseconds your can spend in a frame, if you want to
|
|
3
4
|
* reach a frame rate of 60 FPS.
|
|
@@ -29,12 +30,7 @@ export class RenderLoop {
|
|
|
29
30
|
/**
|
|
30
31
|
* The time at which we rendered the last frame to the DOM.
|
|
31
32
|
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Our `#main` function bound to this classes
|
|
35
|
-
* for easier invokation through external callers.
|
|
36
|
-
*/
|
|
37
|
-
#boundMain;
|
|
33
|
+
previousTimestampPresent;
|
|
38
34
|
/**
|
|
39
35
|
* Our `#drawFrame` function bound to this classes
|
|
40
36
|
* for easier invokation through external callers.
|
|
@@ -71,8 +67,7 @@ export class RenderLoop {
|
|
|
71
67
|
this.options = options;
|
|
72
68
|
this.renderLoop = renderLoop;
|
|
73
69
|
this.previousTimestampDraw = new Date().getTime();
|
|
74
|
-
this.
|
|
75
|
-
this.#boundMain = this.#main.bind(this);
|
|
70
|
+
this.previousTimestampPresent = this.previousTimestampDraw;
|
|
76
71
|
this.#boundDrawFrame = this.#drawFrame.bind(this);
|
|
77
72
|
}
|
|
78
73
|
/**
|
|
@@ -92,22 +87,13 @@ export class RenderLoop {
|
|
|
92
87
|
* Start the render loop.
|
|
93
88
|
*/
|
|
94
89
|
unblock() {
|
|
95
|
-
this.frameRequestId = window.requestAnimationFrame(this.#
|
|
96
|
-
if (!this.drawTimeout) {
|
|
97
|
-
this.drawTimeout = setTimeout(this.#boundDrawFrame);
|
|
98
|
-
}
|
|
90
|
+
this.frameRequestId = window.requestAnimationFrame(this.#boundDrawFrame);
|
|
99
91
|
}
|
|
100
92
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
93
|
+
* The duration it took to produce previous frames.
|
|
94
|
+
* This is used for the frame graph.
|
|
103
95
|
*/
|
|
104
|
-
#
|
|
105
|
-
const timeDelta = timestamp - this.previousTimestampRender;
|
|
106
|
-
this.#renderFrame(timeDelta);
|
|
107
|
-
this.unblock();
|
|
108
|
-
this.previousTimestampRender = timestamp;
|
|
109
|
-
++this.#frameCounter;
|
|
110
|
-
}
|
|
96
|
+
#frameTimes = [];
|
|
111
97
|
/**
|
|
112
98
|
* Draws a new frame to the offscreen buffer.
|
|
113
99
|
*/
|
|
@@ -119,27 +105,59 @@ export class RenderLoop {
|
|
|
119
105
|
const timeDelta = timestamp - this.previousTimestampDraw;
|
|
120
106
|
this.renderLoop(timeDelta, timestamp);
|
|
121
107
|
const frameTime = new Date().getTime() - timestamp;
|
|
122
|
-
|
|
108
|
+
if (this.options.drawFps) {
|
|
109
|
+
this.#frameTimes.push(frameTime);
|
|
110
|
+
}
|
|
123
111
|
this.previousTimestampDraw = timestamp;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Draw a new frame.
|
|
127
|
-
* @param delta The delta to the timestamp of the previous frame.
|
|
128
|
-
*/
|
|
129
|
-
#renderFrame(delta) {
|
|
130
112
|
this.canvas.update();
|
|
131
113
|
if (this.options.onRefresh === "clear") {
|
|
132
114
|
this.canvas.clearWith(0);
|
|
133
115
|
}
|
|
134
116
|
if (this.options.drawFps) {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
117
|
+
const maxFrameTime = this.#frameTimes.reduce((max, frameTime) => {
|
|
118
|
+
if (max < frameTime) {
|
|
119
|
+
max = frameTime;
|
|
120
|
+
}
|
|
121
|
+
return max;
|
|
122
|
+
}, 0);
|
|
123
|
+
const sumFrameTimes = this.#frameTimes.reduce((sum, frameTime) => sum + frameTime, 0);
|
|
124
|
+
const fpsAll = Math.round(this.#frameTimes.length / (sumFrameTimes / 1000)).toString();
|
|
125
|
+
const fpsFrame = 1000 / frameTime;
|
|
126
|
+
const fpsDelta = 1000 / timeDelta;
|
|
127
|
+
this.#frameTimes.splice(0, this.#frameTimes.length - this.canvas.width);
|
|
128
|
+
const frameTimes = this.#frameTimes.toReversed();
|
|
129
|
+
let currentX = this.canvas.width;
|
|
130
|
+
for (const frameTime of frameTimes) {
|
|
131
|
+
let fillColor = 0x00ff00ff;
|
|
132
|
+
let width = 1;
|
|
133
|
+
if (MS_PER_FRAME_60FPS < frameTime) {
|
|
134
|
+
const quality = frameTime / maxFrameTime;
|
|
135
|
+
fillColor = blend(0x00ff00ff, 0xff0000ff, Math.trunc(quality * 255)) >>> 0;
|
|
136
|
+
width = Math.round(frameTime / MS_PER_FRAME_60FPS);
|
|
137
|
+
}
|
|
138
|
+
this.canvas.context.fillStyle = `#${fillColor.toString(16).padStart(8, "0")}`;
|
|
139
|
+
this.canvas.context.globalAlpha = 255;
|
|
140
|
+
this.canvas.context.fillRect(currentX - width, this.canvas.height, width, (frameTime / Math.max(100, maxFrameTime)) * -100);
|
|
141
|
+
currentX -= width;
|
|
142
|
+
}
|
|
143
|
+
this.canvas.context.beginPath();
|
|
144
|
+
this.canvas.context.strokeStyle = "#fff";
|
|
145
|
+
this.canvas.context.moveTo(0, this.canvas.height - MS_PER_FRAME_60FPS);
|
|
146
|
+
this.canvas.context.lineTo(this.canvas.width, this.canvas.height - MS_PER_FRAME_60FPS);
|
|
147
|
+
this.canvas.context.stroke();
|
|
148
|
+
const fpsString = `${Math.round(fpsFrame)}f ${fpsAll}∑ ${Math.round(fpsDelta)}δ`;
|
|
149
|
+
this.canvas.context.font = "13px monospace";
|
|
150
|
+
this.canvas.context.strokeStyle = "rgba( 255, 255, 255, 1)";
|
|
151
|
+
this.canvas.context.textAlign = "right";
|
|
152
|
+
this.canvas.context.textRendering = "geometricPrecision";
|
|
153
|
+
this.canvas.context.strokeText(fpsString, this.canvas.width - 3, this.canvas.height - 3);
|
|
139
154
|
this.canvas.context.fillStyle = "#000000";
|
|
140
|
-
this.canvas.context.fillText(
|
|
155
|
+
this.canvas.context.fillText(fpsString, this.canvas.width - 3, this.canvas.height - 3);
|
|
141
156
|
}
|
|
142
157
|
this.canvas.render();
|
|
158
|
+
this.unblock();
|
|
159
|
+
this.previousTimestampPresent = timestamp;
|
|
160
|
+
++this.#frameCounter;
|
|
143
161
|
}
|
|
144
162
|
}
|
|
145
163
|
//# sourceMappingURL=render-loop.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-loop.js","sourceRoot":"","sources":["../../source/graphics/render-loop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"render-loop.js","sourceRoot":"","sources":["../../source/graphics/render-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AAC;YACzD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;YACzF,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;YAC1C,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;SACxF;QAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAErB,IAAI,CAAC,OAAO,EAAE,CAAC;QAEf,IAAI,CAAC,wBAAwB,GAAG,SAAS,CAAC;QAC1C,EAAE,IAAI,CAAC,aAAa,CAAC;IACvB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@oliversalzburg/js-utils",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.16",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
|
|
7
7
|
"type": "module",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@types/mocha": "10.0.4",
|
|
39
39
|
"@types/node": "20.9.0",
|
|
40
40
|
"@types/web": "0.0.119",
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
42
|
-
"@typescript-eslint/parser": "6.
|
|
41
|
+
"@typescript-eslint/eslint-plugin": "6.11.0",
|
|
42
|
+
"@typescript-eslint/parser": "6.11.0",
|
|
43
43
|
"c8": "8.0.1",
|
|
44
44
|
"chai": "4.3.10",
|
|
45
45
|
"chai-as-promised": "7.1.1",
|
package/_site/favicon.ico
DELETED
|
Binary file
|
package/lib/Async.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const executeAsyncContext: (context: () => Promise<unknown>, resolve?: ((value: unknown) => void) | undefined, reject?: ((error: Error) => void) | undefined) => undefined;
|
|
2
|
-
export declare const prepareAsyncContext: (context: () => Promise<unknown>) => () => undefined;
|
|
3
|
-
export declare const coalesceOnError: <TExecutableReturn, T>(executable: (...args: Array<unknown>) => Promise<TExecutableReturn>, to: T) => Promise<TExecutableReturn | T>;
|
package/lib/Async.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const executeAsyncContext = (context, resolve, reject) => {
|
|
2
|
-
return void context()
|
|
3
|
-
.then(resolve ?? (() => undefined))
|
|
4
|
-
.catch(reject ?? console.error);
|
|
5
|
-
};
|
|
6
|
-
export const prepareAsyncContext = (context) => {
|
|
7
|
-
return () => executeAsyncContext(context);
|
|
8
|
-
};
|
|
9
|
-
export const coalesceOnError = async (executable, to) => {
|
|
10
|
-
try {
|
|
11
|
-
return await executable();
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
return to;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=Async.js.map
|
package/lib/Async.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Async.js","sourceRoot":"","sources":["../source/Async.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAA+B,EAC/B,OAAkC,EAClC,MAA+B,EAC/B,EAAE;IACF,OAAO,KAAK,OAAO,EAAE;SAClB,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;SAClC,KAAK,CAAC,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAA+B,EAAE,EAAE;IACrE,OAAO,GAAG,EAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,UAAmE,EACnE,EAAK,EACL,EAAE;IACF,IAAI;QACF,OAAO,MAAM,UAAU,EAAE,CAAC;KAC3B;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,EAAE,CAAC;KACX;AACH,CAAC,CAAC"}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/// <reference types="@types/web" />
|
|
2
|
-
/**
|
|
3
|
-
* Construction options for a {@linkcode Canvas}.
|
|
4
|
-
* @group Graphics
|
|
5
|
-
*/
|
|
6
|
-
export interface CanvasOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Was this {@linkcode Canvas} created with the ability to copy the front buffer back into
|
|
9
|
-
* the back buffer?
|
|
10
|
-
*/
|
|
11
|
-
readonly supportReadBack: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The {@linkcode Canvas} is a double-buffered construct to help with drawing to a
|
|
15
|
-
* {@linkcode !HTMLCanvasElement} with best possible performance.
|
|
16
|
-
* We utilize an {@linkcode !OffscreenCanvas} with a {@linkcode !OffscreenCanvasRenderingContext2D}
|
|
17
|
-
* to draw frames and expect to render them back to the DOM in regular intervals.
|
|
18
|
-
* @group Graphics
|
|
19
|
-
*/
|
|
20
|
-
export declare class Canvas {
|
|
21
|
-
#private;
|
|
22
|
-
/**
|
|
23
|
-
* The {@linkcode !HTMLCanvasElement} we're interacting with in the DOM.
|
|
24
|
-
*/
|
|
25
|
-
readonly canvasDom: HTMLCanvasElement | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* The width of the canvas.
|
|
28
|
-
*/
|
|
29
|
-
readonly width: number;
|
|
30
|
-
/**
|
|
31
|
-
* The height of the canvas.
|
|
32
|
-
*/
|
|
33
|
-
readonly height: number;
|
|
34
|
-
/**
|
|
35
|
-
* The {@linkcode !OffscreenCanvasRenderingContext2D} we're using to draw to the canvas.
|
|
36
|
-
*/
|
|
37
|
-
readonly context: OffscreenCanvasRenderingContext2D | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* Our back buffer.
|
|
40
|
-
*/
|
|
41
|
-
buffer: Uint8ClampedArray | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* The configuration that was used for this canvas.
|
|
44
|
-
*/
|
|
45
|
-
readonly options: Readonly<Partial<CanvasOptions>>;
|
|
46
|
-
constructor(canvas: OffscreenCanvas);
|
|
47
|
-
/**
|
|
48
|
-
* Constructs a new {@linkcode Canvas}.
|
|
49
|
-
* @param canvas The canvas to wrap.
|
|
50
|
-
* @param worker
|
|
51
|
-
* @param options The configuration for this canvas.
|
|
52
|
-
*/
|
|
53
|
-
constructor(canvas: HTMLCanvasElement, worker: Worker, options?: Partial<CanvasOptions>);
|
|
54
|
-
static reconstruct(canvasOffscreen: OffscreenCanvas): Canvas;
|
|
55
|
-
/**
|
|
56
|
-
* Draws the back buffer onto the canvas.
|
|
57
|
-
*/
|
|
58
|
-
update(): void;
|
|
59
|
-
/**
|
|
60
|
-
* Draws the offscreen canvas into the DOM canvas.
|
|
61
|
-
*/
|
|
62
|
-
render(): void;
|
|
63
|
-
/**
|
|
64
|
-
* Draws a slightly transparent, black rectangle over the canvas,
|
|
65
|
-
* and then reads the result back into the buffer.
|
|
66
|
-
* @param color The color to fade the buffer with. The alpha component of
|
|
67
|
-
* the color defines how strong the fade is. `0` is not at all, `255` makes
|
|
68
|
-
* it instantly black.
|
|
69
|
-
*/
|
|
70
|
-
fade(color?: number): void;
|
|
71
|
-
/**
|
|
72
|
-
* Reads the front buffer back into the back buffer.
|
|
73
|
-
*/
|
|
74
|
-
bufferReadBack(): void;
|
|
75
|
-
/**
|
|
76
|
-
* Returns the color of a pixel in the back buffer.
|
|
77
|
-
* @param x The X coordinate to retrieve.
|
|
78
|
-
* @param y The X coordinate to retrieve.
|
|
79
|
-
* @returns The color of the pixel at the given local.
|
|
80
|
-
*/
|
|
81
|
-
getPixel32(x: number, y: number): number;
|
|
82
|
-
/**
|
|
83
|
-
* Colors a pixel in the back buffer.
|
|
84
|
-
* @param x The X coordinate to color.
|
|
85
|
-
* @param y The Y coordinate to color.
|
|
86
|
-
* @param color The color to place at the coordinate.
|
|
87
|
-
*/
|
|
88
|
-
setPixel32(x: number, y: number, color: number): void;
|
|
89
|
-
/**
|
|
90
|
-
* Fills the entire back buffer with the given color.
|
|
91
|
-
* @param color The color to fill the back buffer with.
|
|
92
|
-
*/
|
|
93
|
-
clearWith(color: number): void;
|
|
94
|
-
/**
|
|
95
|
-
* Fills the entire back buffer with the given color.
|
|
96
|
-
* @param color The color to fill the back buffer with.
|
|
97
|
-
*/
|
|
98
|
-
blendWith(color: number): void;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Linearly blends a new pixel with an existing color value in a {@linkcode Canvas}.
|
|
102
|
-
*
|
|
103
|
-
* As this method is often called many times in render loops, only bounds
|
|
104
|
-
* checking is applied to the given coordinates.
|
|
105
|
-
*
|
|
106
|
-
* The coordinates are **expected to already be integers**. Supplying numbers with fractions
|
|
107
|
-
* has performance implications. Ensure you're working with integers, or truncate the
|
|
108
|
-
* coordinates before passing them in.
|
|
109
|
-
*
|
|
110
|
-
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
111
|
-
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
112
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
113
|
-
* @param x The X coordinate at which to place the pixel.
|
|
114
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
115
|
-
* @param color The color of the pixel.
|
|
116
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
117
|
-
* @group Graphics
|
|
118
|
-
*/
|
|
119
|
-
export declare const putPixel32: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|
|
120
|
-
/**
|
|
121
|
-
* Additively blends a new pixel with an existing color value in a {@linkcode Canvas}.
|
|
122
|
-
*
|
|
123
|
-
* As this method is often called many times in render loops, only bounds
|
|
124
|
-
* checking is applied to the given coordinates.
|
|
125
|
-
*
|
|
126
|
-
* The coordinates are **expected to already be integers**. Supplying numbers with fractions
|
|
127
|
-
* has performance implications. Ensure you're working with integers, or truncate the
|
|
128
|
-
* coordinates before passing them in.
|
|
129
|
-
*
|
|
130
|
-
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
131
|
-
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
132
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
133
|
-
* @param x The X coordinate at which to place the pixel.
|
|
134
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
135
|
-
* @param color The color of the pixel.
|
|
136
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
137
|
-
* @group Graphics
|
|
138
|
-
*/
|
|
139
|
-
export declare const putPixel32Add: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|
|
140
|
-
/**
|
|
141
|
-
* Subtractively blends a new pixel with an existing color value in a {@linkcode Canvas}.
|
|
142
|
-
*
|
|
143
|
-
* As this method is often called many times in render loops, only bounds
|
|
144
|
-
* checking is applied to the given coordinates.
|
|
145
|
-
*
|
|
146
|
-
* The coordinates are **expected to already be integers**. Supplying numbers with fractions
|
|
147
|
-
* has performance implications. Ensure you're working with integers, or truncate the
|
|
148
|
-
* coordinates before passing them in.
|
|
149
|
-
*
|
|
150
|
-
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
151
|
-
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
152
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
153
|
-
* @param x The X coordinate at which to place the pixel.
|
|
154
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
155
|
-
* @param color The color of the pixel.
|
|
156
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
157
|
-
* @group Graphics
|
|
158
|
-
*/
|
|
159
|
-
export declare const putPixel32Sub: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|
|
160
|
-
/**
|
|
161
|
-
* Linearly blends a new pixel with an existing color value in a {@linkcode Canvas}.
|
|
162
|
-
* Compared to {@linkcode putPixel32}, this function supports sub-pixel placement, but is dramatically slower.
|
|
163
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
164
|
-
* @param x The X coordinate at which to place the pixel.
|
|
165
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
166
|
-
* @param color The color of the pixel.
|
|
167
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
168
|
-
* @group Graphics
|
|
169
|
-
*/
|
|
170
|
-
export declare const putSubPixel32: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|