@oliversalzburg/js-utils 0.0.18 → 0.0.19-dev.0
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/array.d.ts +39 -0
- package/{lib/array.js → array.js} +12 -13
- package/array.js.map +1 -0
- package/async.d.ts +28 -0
- package/{lib/async.js → async.js} +16 -10
- package/async.js.map +1 -0
- package/async.test.js +28 -0
- package/async.test.js.map +1 -0
- package/core.d.ts +36 -0
- package/core.js +3 -0
- package/core.js.map +1 -0
- package/{lib/dom → dom}/core.d.ts +8 -8
- package/{lib/dom → dom}/core.js +8 -8
- package/{lib/error-serializer.d.ts → error-serializer.d.ts} +5 -5
- package/{lib/error-serializer.js → error-serializer.js} +5 -5
- package/{lib/errors → errors}/AbstractError.d.ts +5 -5
- package/{lib/errors → errors}/AbstractError.js +5 -5
- package/{lib/errors → errors}/InternalError.d.ts +3 -3
- package/{lib/errors → errors}/InternalError.js +3 -3
- package/{lib/errors → errors}/InvalidArgumentError.d.ts +2 -2
- package/{lib/errors → errors}/InvalidArgumentError.js +2 -2
- package/{lib/errors → errors}/InvalidOperationError.d.ts +2 -2
- package/{lib/errors → errors}/InvalidOperationError.js +2 -2
- package/{lib/errors → errors}/NotImplementedError.d.ts +2 -2
- package/{lib/errors → errors}/NotImplementedError.js +2 -2
- package/{lib/errors → errors}/PermissionViolationError.d.ts +2 -2
- package/{lib/errors → errors}/PermissionViolationError.js +2 -2
- package/{lib/errors → errors}/ResourceConflictError.d.ts +2 -2
- package/{lib/errors → errors}/ResourceConflictError.js +2 -2
- package/{lib/errors → errors}/UnknownError.d.ts +2 -2
- package/{lib/errors → errors}/UnknownError.js +2 -2
- package/{lib/graphics → graphics}/canvas-sandbox.d.ts +13 -13
- package/{lib/graphics → graphics}/canvas-sandbox.js +9 -9
- package/{lib/graphics → graphics}/canvas.d.ts +30 -30
- package/{lib/graphics → graphics}/canvas.js +30 -30
- package/{lib/graphics → graphics}/core.d.ts +23 -23
- package/{lib/graphics → graphics}/core.js +23 -24
- package/{lib/graphics → graphics}/core.js.map +1 -1
- package/{lib/graphics → graphics}/render-loop.d.ts +3 -3
- package/{lib/graphics → graphics}/render-loop.js +3 -3
- package/{lib/math → math}/core.d.ts +19 -10
- package/{lib/math → math}/core.js +21 -10
- package/{lib/math → math}/core.js.map +1 -1
- package/{lib/math → math}/euler.d.ts +4 -4
- package/{lib/math → math}/euler.js +4 -4
- package/{lib/math → math}/matrix3.d.ts +34 -34
- package/{lib/math → math}/matrix3.js +34 -34
- package/{lib/math → math}/quaternion.d.ts +25 -25
- package/{lib/math → math}/quaternion.js +25 -25
- package/{lib/math → math}/transformation.d.ts +3 -3
- package/{lib/math → math}/transformation.js +3 -3
- package/{lib/math → math}/vector2.d.ts +40 -40
- package/{lib/math → math}/vector2.js +40 -40
- package/{lib/math → math}/vector3.d.ts +66 -66
- package/{lib/math → math}/vector3.js +66 -66
- package/{lib/math → math}/vector4.d.ts +38 -38
- package/{lib/math → math}/vector4.js +38 -38
- package/{lib/nil.d.ts → nil.d.ts} +11 -9
- package/{lib/nil.js → nil.js} +10 -9
- package/{lib/nil.js.map → nil.js.map} +1 -1
- package/package.json +16 -18
- package/{lib/random.d.ts → random.d.ts} +11 -17
- package/{lib/random.js → random.js} +11 -17
- package/random.js.map +1 -0
- package/{lib/sleep.d.ts → sleep.d.ts} +1 -1
- package/{lib/sleep.js → sleep.js} +1 -1
- package/{lib/string-formatter.d.ts → string-formatter.d.ts} +8 -4
- package/{lib/string-formatter.js → string-formatter.js} +8 -4
- package/string-formatter.js.map +1 -0
- package/string-formatter.test.d.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/LICENSES.md +0 -17
- package/_site/assets/highlight.css +0 -141
- package/_site/assets/main.js +0 -59
- package/_site/assets/navigation.js +0 -1
- package/_site/assets/search.js +0 -1
- package/_site/assets/style.css +0 -1383
- package/_site/classes/AbstractError.html +0 -67
- package/_site/classes/Canvas.html +0 -106
- package/_site/classes/CanvasSandbox.html +0 -91
- package/_site/classes/Euler.html +0 -217
- package/_site/classes/InternalError.html +0 -71
- package/_site/classes/InvalidArgumentError.html +0 -67
- package/_site/classes/InvalidOperationError.html +0 -67
- package/_site/classes/Matrix3.html +0 -167
- package/_site/classes/NotImplementedError.html +0 -66
- package/_site/classes/PermissionViolationError.html +0 -67
- package/_site/classes/Quaternion.html +0 -211
- package/_site/classes/Random.html +0 -90
- package/_site/classes/RenderLoop.html +0 -85
- package/_site/classes/ResourceConflictError.html +0 -66
- package/_site/classes/Transformation.html +0 -52
- package/_site/classes/UnexpectedNilError.html +0 -54
- package/_site/classes/UnknownError.html +0 -70
- package/_site/classes/Vector2.html +0 -159
- package/_site/classes/Vector3.html +0 -214
- package/_site/classes/Vector4.html +0 -156
- package/_site/functions/addVector2.html +0 -44
- package/_site/functions/addVector3.html +0 -44
- package/_site/functions/blend.html +0 -47
- package/_site/functions/blendAdditive.html +0 -47
- package/_site/functions/blendSubtractive.html +0 -47
- package/_site/functions/clamp.html +0 -45
- package/_site/functions/coalesceOnRejection.html +0 -51
- package/_site/functions/cosDeg.html +0 -43
- package/_site/functions/crossVector3.html +0 -44
- package/_site/functions/deg2rad.html +0 -43
- package/_site/functions/difference.html +0 -46
- package/_site/functions/distance.html +0 -46
- package/_site/functions/dotVector3.html +0 -44
- package/_site/functions/errorToJSON.html +0 -43
- package/_site/functions/errorToRecord.html +0 -43
- package/_site/functions/errorToSimpleSerializable.html +0 -43
- package/_site/functions/filterType.html +0 -46
- package/_site/functions/formatString.html +0 -46
- package/_site/functions/formatStringTemplate.html +0 -46
- package/_site/functions/fromRGB.html +0 -46
- package/_site/functions/fromRGBA.html +0 -46
- package/_site/functions/getA.html +0 -43
- package/_site/functions/getB.html +0 -43
- package/_site/functions/getDocumentElementTypeById.html +0 -46
- package/_site/functions/getDocumentElementTypeByIdStrict.html +0 -48
- package/_site/functions/getG.html +0 -43
- package/_site/functions/getR.html +0 -43
- package/_site/functions/intersect.html +0 -47
- package/_site/functions/is.html +0 -46
- package/_site/functions/isError.html +0 -43
- package/_site/functions/isInteger.html +0 -43
- package/_site/functions/isNil.html +0 -44
- package/_site/functions/isqrt.html +0 -43
- package/_site/functions/multiplyVector2.html +0 -44
- package/_site/functions/multiplyVector3.html +0 -44
- package/_site/functions/mustExist.html +0 -45
- package/_site/functions/nextPalette.html +0 -42
- package/_site/functions/prepareAsyncContext.html +0 -46
- package/_site/functions/putPixel32.html +0 -53
- package/_site/functions/putPixel32Add.html +0 -53
- package/_site/functions/putPixel32Sub.html +0 -53
- package/_site/functions/putSubPixel32.html +0 -47
- package/_site/functions/rad2deg.html +0 -43
- package/_site/functions/randomRange.html +0 -45
- package/_site/functions/safeRGBComponent.html +0 -43
- package/_site/functions/seedFromString.html +0 -44
- package/_site/functions/shuffleArray.html +0 -44
- package/_site/functions/sinDeg.html +0 -43
- package/_site/functions/sleep.html +0 -43
- package/_site/functions/somecolor.html +0 -43
- package/_site/functions/subtractVector2.html +0 -44
- package/_site/functions/subtractVector3.html +0 -44
- package/_site/functions/toGrayScale.html +0 -43
- package/_site/functions/unknownToError.html +0 -45
- package/_site/index.html +0 -44
- package/_site/interfaces/CanvasOptions.html +0 -44
- package/_site/interfaces/CanvasSandboxApplication.html +0 -60
- package/_site/interfaces/CanvasSandboxExpectedOptions.html +0 -48
- package/_site/interfaces/CanvasSandboxOptions.html +0 -45
- package/_site/interfaces/RenderLoopOptions.html +0 -46
- package/_site/modules.html +0 -134
- package/_site/types/AnyAsyncFunction.html +0 -41
- package/_site/types/AnyConstructor.html +0 -41
- package/_site/types/AnyFunction.html +0 -41
- package/_site/types/ConstructorOf.html +0 -41
- package/_site/types/FunctionReturning.html +0 -41
- package/_site/types/Maybe.html +0 -41
- package/_site/types/Mixin.html +0 -42
- package/_site/types/Nil.html +0 -42
- package/_site/types/RenderLoopCallback.html +0 -41
- package/_site/types/SerializedError.html +0 -41
- package/_site/variables/CANVAS_SANDBOX_DEFAULT_CSS.html +0 -41
- package/_site/variables/MS_PER_FRAME_60FPS.html +0 -42
- package/_site/variables/PALETTES.html +0 -41
- package/_site/variables/TWO_PI.html +0 -41
- package/_site/variables/random-1.html +0 -41
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/bundle.js +0 -30
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -16
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/spa.css +0 -298
- package/coverage/string-formatter.ts.html +0 -187
- package/coverage/tmp/coverage-4186-1699218521999-0.json +0 -1
- package/coverage/tmp/coverage-4196-1699218521967-0.json +0 -1
- package/docs/assets/favicon.ico +0 -0
- package/lib/array.d.ts +0 -40
- package/lib/array.js.map +0 -1
- package/lib/async.d.ts +0 -27
- package/lib/async.js.map +0 -1
- package/lib/core.d.ts +0 -33
- package/lib/core.js +0 -12
- package/lib/core.js.map +0 -1
- package/lib/random.js.map +0 -1
- package/lib/string-formatter.js.map +0 -1
- package/mkdocs.yml +0 -52
- /package/{lib/error-serializer.test.d.ts → async.test.d.ts} +0 -0
- /package/{lib/dom → dom}/core.js.map +0 -0
- /package/{lib/dom → dom}/index.d.ts +0 -0
- /package/{lib/dom → dom}/index.js +0 -0
- /package/{lib/dom → dom}/index.js.map +0 -0
- /package/{lib/error-serializer.js.map → error-serializer.js.map} +0 -0
- /package/{lib/string-formatter.test.d.ts → error-serializer.test.d.ts} +0 -0
- /package/{lib/error-serializer.test.js → error-serializer.test.js} +0 -0
- /package/{lib/error-serializer.test.js.map → error-serializer.test.js.map} +0 -0
- /package/{lib/errors → errors}/AbstractError.js.map +0 -0
- /package/{lib/errors → errors}/InternalError.js.map +0 -0
- /package/{lib/errors → errors}/InvalidArgumentError.js.map +0 -0
- /package/{lib/errors → errors}/InvalidOperationError.js.map +0 -0
- /package/{lib/errors → errors}/NotImplementedError.js.map +0 -0
- /package/{lib/errors → errors}/PermissionViolationError.js.map +0 -0
- /package/{lib/errors → errors}/ResourceConflictError.js.map +0 -0
- /package/{lib/errors → errors}/UnknownError.js.map +0 -0
- /package/{lib/errors → errors}/index.d.ts +0 -0
- /package/{lib/errors → errors}/index.js +0 -0
- /package/{lib/errors → errors}/index.js.map +0 -0
- /package/{lib/graphics → graphics}/canvas-sandbox.js.map +0 -0
- /package/{lib/graphics → graphics}/canvas.js.map +0 -0
- /package/{lib/graphics → graphics}/index.d.ts +0 -0
- /package/{lib/graphics → graphics}/index.js +0 -0
- /package/{lib/graphics → graphics}/index.js.map +0 -0
- /package/{lib/graphics → graphics}/render-loop.js.map +0 -0
- /package/{lib/index.d.ts → index.d.ts} +0 -0
- /package/{lib/index.js → index.js} +0 -0
- /package/{lib/index.js.map → index.js.map} +0 -0
- /package/{lib/math → math}/euler.js.map +0 -0
- /package/{lib/math → math}/index.d.ts +0 -0
- /package/{lib/math → math}/index.js +0 -0
- /package/{lib/math → math}/index.js.map +0 -0
- /package/{lib/math → math}/matrix3.js.map +0 -0
- /package/{lib/math → math}/quaternion.js.map +0 -0
- /package/{lib/math → math}/transformation.js.map +0 -0
- /package/{lib/math → math}/vector2.js.map +0 -0
- /package/{lib/math → math}/vector3.js.map +0 -0
- /package/{lib/math → math}/vector4.js.map +0 -0
- /package/{lib/sleep.js.map → sleep.js.map} +0 -0
- /package/{lib/string-formatter.test.js → string-formatter.test.js} +0 -0
- /package/{lib/string-formatter.test.js.map → string-formatter.test.js.map} +0 -0
|
@@ -26,7 +26,7 @@ export interface CanvasSandboxExpectedOptions {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Describes an application running inside the {@linkcode CanvasSandbox}.
|
|
29
|
-
* @
|
|
29
|
+
* @typeParam TApplicationOptions - The type of the options object
|
|
30
30
|
* with which the application is constructed.
|
|
31
31
|
* @group Graphics
|
|
32
32
|
*/
|
|
@@ -46,14 +46,14 @@ export interface CanvasSandboxApplication<TApplicationOptions extends CanvasSand
|
|
|
46
46
|
paused: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Request the application to draw a new frame.
|
|
49
|
-
* @param delta How many milliseconds passed since the last frame draw.
|
|
50
|
-
* @param timestamp The current timestamp.
|
|
49
|
+
* @param delta - How many milliseconds passed since the last frame draw.
|
|
50
|
+
* @param timestamp - The current timestamp.
|
|
51
51
|
*/
|
|
52
52
|
onDraw(delta: number, timestamp: number): void;
|
|
53
53
|
/**
|
|
54
54
|
* Reconfigure the application with the given options and restart it.
|
|
55
|
-
* @param canvas The canvas to use.
|
|
56
|
-
* @param options The new options to use.
|
|
55
|
+
* @param canvas - The canvas to use.
|
|
56
|
+
* @param options - The new options to use.
|
|
57
57
|
*/
|
|
58
58
|
reconfigure(canvas: Canvas, options?: Partial<TApplicationOptions>): void;
|
|
59
59
|
/**
|
|
@@ -68,12 +68,12 @@ export interface CanvasSandboxApplication<TApplicationOptions extends CanvasSand
|
|
|
68
68
|
export interface CanvasSandboxOptions {
|
|
69
69
|
/**
|
|
70
70
|
* Should the sandbox render developer information?
|
|
71
|
-
* @
|
|
71
|
+
* @defaultValue false
|
|
72
72
|
*/
|
|
73
73
|
devMode: boolean;
|
|
74
74
|
/**
|
|
75
75
|
* Should the sandbox default CSS be injected into the body?
|
|
76
|
-
* @
|
|
76
|
+
* @defaultValue true
|
|
77
77
|
*/
|
|
78
78
|
injectDefaultCss: boolean;
|
|
79
79
|
}
|
|
@@ -144,7 +144,7 @@ export interface CanvasSandboxOptions {
|
|
|
144
144
|
* <script src="main.ts" type="module"></script>
|
|
145
145
|
* </html>
|
|
146
146
|
* ```
|
|
147
|
-
* @
|
|
147
|
+
* @typeParam TApplicationOptions - The type of the options
|
|
148
148
|
* the application in the sandbox will be constructed with.
|
|
149
149
|
* @group Graphics
|
|
150
150
|
*/
|
|
@@ -177,11 +177,11 @@ export declare class CanvasSandbox<TApplicationOptions extends CanvasSandboxExpe
|
|
|
177
177
|
readonly renderLoop: RenderLoop;
|
|
178
178
|
/**
|
|
179
179
|
* Construct a new {@linkcode CanvasSandbox}.
|
|
180
|
-
* @param window The window we're running inside.
|
|
181
|
-
* @param canvasNode The canvas node we're drawing to.
|
|
182
|
-
* @param Application The application that is going to run in the sandbox.
|
|
183
|
-
* @param options The options that the application should be constructed with.
|
|
184
|
-
* @param sandboxOptions The options for the sandbox itself.
|
|
180
|
+
* @param window - The window we're running inside.
|
|
181
|
+
* @param canvasNode - The canvas node we're drawing to.
|
|
182
|
+
* @param Application - The application that is going to run in the sandbox.
|
|
183
|
+
* @param options - The options that the application should be constructed with.
|
|
184
|
+
* @param sandboxOptions - The options for the sandbox itself.
|
|
185
185
|
*/
|
|
186
186
|
constructor(window: Window, canvasNode: HTMLCanvasElement, Application: new (
|
|
187
187
|
/**
|
|
@@ -7,8 +7,8 @@ import { RenderLoop } from "./render-loop.js";
|
|
|
7
7
|
* Provides the input as-is.
|
|
8
8
|
* This method exists only to make use of the `css` template string tag,
|
|
9
9
|
* which allows us to use in-IDE support for CSS through the support for
|
|
10
|
-
* {@link https://lit.dev/docs/components/styles/ Lit styles}.
|
|
11
|
-
* @param input The CSS code.
|
|
10
|
+
* {@link https://lit.dev/docs/components/styles/ | Lit styles}.
|
|
11
|
+
* @param input - The CSS code.
|
|
12
12
|
* @returns The CSS code as-is.
|
|
13
13
|
*/
|
|
14
14
|
const css = (input) => input.join("");
|
|
@@ -116,7 +116,7 @@ export const CANVAS_SANDBOX_DEFAULT_CSS = /* PURE */ css `
|
|
|
116
116
|
* <script src="main.ts" type="module"></script>
|
|
117
117
|
* </html>
|
|
118
118
|
* ```
|
|
119
|
-
* @
|
|
119
|
+
* @typeParam TApplicationOptions - The type of the options
|
|
120
120
|
* the application in the sandbox will be constructed with.
|
|
121
121
|
* @group Graphics
|
|
122
122
|
*/
|
|
@@ -152,11 +152,11 @@ export class CanvasSandbox {
|
|
|
152
152
|
#resizeDebounce = null;
|
|
153
153
|
/**
|
|
154
154
|
* Construct a new {@linkcode CanvasSandbox}.
|
|
155
|
-
* @param window The window we're running inside.
|
|
156
|
-
* @param canvasNode The canvas node we're drawing to.
|
|
157
|
-
* @param Application The application that is going to run in the sandbox.
|
|
158
|
-
* @param options The options that the application should be constructed with.
|
|
159
|
-
* @param sandboxOptions The options for the sandbox itself.
|
|
155
|
+
* @param window - The window we're running inside.
|
|
156
|
+
* @param canvasNode - The canvas node we're drawing to.
|
|
157
|
+
* @param Application - The application that is going to run in the sandbox.
|
|
158
|
+
* @param options - The options that the application should be constructed with.
|
|
159
|
+
* @param sandboxOptions - The options for the sandbox itself.
|
|
160
160
|
*/
|
|
161
161
|
constructor(window, canvasNode, Application, options, sandboxOptions) {
|
|
162
162
|
this.window = window;
|
|
@@ -243,7 +243,7 @@ export class CanvasSandbox {
|
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
245
|
* Reconfigures, and then restarts, the application.
|
|
246
|
-
* @param options The new options for the application.
|
|
246
|
+
* @param options - The new options for the application.
|
|
247
247
|
*/
|
|
248
248
|
#reconfigureApplication(options = {}) {
|
|
249
249
|
this.application.reconfigure(this.canvas, options);
|
|
@@ -48,8 +48,8 @@ export declare class Canvas {
|
|
|
48
48
|
readonly options: Readonly<Partial<CanvasOptions>>;
|
|
49
49
|
/**
|
|
50
50
|
* Constructs a new {@linkcode Canvas}.
|
|
51
|
-
* @param canvas The canvas to wrap.
|
|
52
|
-
* @param options The configuration for this canvas.
|
|
51
|
+
* @param canvas - The canvas to wrap.
|
|
52
|
+
* @param options - The configuration for this canvas.
|
|
53
53
|
*/
|
|
54
54
|
constructor(canvas: HTMLCanvasElement, options?: Partial<CanvasOptions>);
|
|
55
55
|
/**
|
|
@@ -67,7 +67,7 @@ export declare class Canvas {
|
|
|
67
67
|
/**
|
|
68
68
|
* Draws a slightly transparent, black rectangle over the canvas,
|
|
69
69
|
* and then reads the result back into the buffer.
|
|
70
|
-
* @param color The color to fade the buffer with. The alpha component of
|
|
70
|
+
* @param color - The color to fade the buffer with. The alpha component of
|
|
71
71
|
* the color defines how strong the fade is. `0` is not at all, `255` makes
|
|
72
72
|
* it instantly black.
|
|
73
73
|
*/
|
|
@@ -78,26 +78,26 @@ export declare class Canvas {
|
|
|
78
78
|
bufferReadBack(): void;
|
|
79
79
|
/**
|
|
80
80
|
* Returns the color of a pixel in the back buffer.
|
|
81
|
-
* @param x The X coordinate to retrieve.
|
|
82
|
-
* @param y The X coordinate to retrieve.
|
|
81
|
+
* @param x - The X coordinate to retrieve.
|
|
82
|
+
* @param y - The X coordinate to retrieve.
|
|
83
83
|
* @returns The color of the pixel at the given local.
|
|
84
84
|
*/
|
|
85
85
|
getPixel32(x: number, y: number): number;
|
|
86
86
|
/**
|
|
87
87
|
* Colors a pixel in the back buffer.
|
|
88
|
-
* @param x The X coordinate to color.
|
|
89
|
-
* @param y The Y coordinate to color.
|
|
90
|
-
* @param color The color to place at the coordinate.
|
|
88
|
+
* @param x - The X coordinate to color.
|
|
89
|
+
* @param y - The Y coordinate to color.
|
|
90
|
+
* @param color - The color to place at the coordinate.
|
|
91
91
|
*/
|
|
92
92
|
setPixel32(x: number, y: number, color: number): void;
|
|
93
93
|
/**
|
|
94
94
|
* Fills the entire back buffer with the given color.
|
|
95
|
-
* @param color The color to fill the back buffer with.
|
|
95
|
+
* @param color - The color to fill the back buffer with.
|
|
96
96
|
*/
|
|
97
97
|
clearWith(color: number): void;
|
|
98
98
|
/**
|
|
99
99
|
* Fills the entire back buffer with the given color.
|
|
100
|
-
* @param color The color to fill the back buffer with.
|
|
100
|
+
* @param color - The color to fill the back buffer with.
|
|
101
101
|
*/
|
|
102
102
|
blendWith(color: number): void;
|
|
103
103
|
}
|
|
@@ -113,11 +113,11 @@ export declare class Canvas {
|
|
|
113
113
|
*
|
|
114
114
|
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
115
115
|
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
116
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
117
|
-
* @param x The X coordinate at which to place the pixel.
|
|
118
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
119
|
-
* @param color The color of the pixel.
|
|
120
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
116
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
117
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
118
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
119
|
+
* @param color - The color of the pixel.
|
|
120
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
121
121
|
* @group Graphics
|
|
122
122
|
*/
|
|
123
123
|
export declare const putPixel32: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|
|
@@ -133,11 +133,11 @@ export declare const putPixel32: (canvas: Canvas, x: number, y: number, color: n
|
|
|
133
133
|
*
|
|
134
134
|
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
135
135
|
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
136
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
137
|
-
* @param x The X coordinate at which to place the pixel.
|
|
138
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
139
|
-
* @param color The color of the pixel.
|
|
140
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
136
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
137
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
138
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
139
|
+
* @param color - The color of the pixel.
|
|
140
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
141
141
|
* @group Graphics
|
|
142
142
|
*/
|
|
143
143
|
export declare const putPixel32Add: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|
|
@@ -153,22 +153,22 @@ export declare const putPixel32Add: (canvas: Canvas, x: number, y: number, color
|
|
|
153
153
|
*
|
|
154
154
|
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
155
155
|
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
156
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
157
|
-
* @param x The X coordinate at which to place the pixel.
|
|
158
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
159
|
-
* @param color The color of the pixel.
|
|
160
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
156
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
157
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
158
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
159
|
+
* @param color - The color of the pixel.
|
|
160
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
161
161
|
* @group Graphics
|
|
162
162
|
*/
|
|
163
163
|
export declare const putPixel32Sub: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|
|
164
164
|
/**
|
|
165
165
|
* Linearly blends a new pixel with an existing color value in a {@linkcode Canvas}.
|
|
166
166
|
* Compared to {@linkcode putPixel32}, this function supports sub-pixel placement, but is dramatically slower.
|
|
167
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
168
|
-
* @param x The X coordinate at which to place the pixel.
|
|
169
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
170
|
-
* @param color The color of the pixel.
|
|
171
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
167
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
168
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
169
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
170
|
+
* @param color - The color of the pixel.
|
|
171
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
172
172
|
* @group Graphics
|
|
173
173
|
*/
|
|
174
174
|
export declare const putSubPixel32: (canvas: Canvas, x: number, y: number, color: number, alpha: number) => void;
|
|
@@ -69,8 +69,8 @@ export class Canvas {
|
|
|
69
69
|
options;
|
|
70
70
|
/**
|
|
71
71
|
* Constructs a new {@linkcode Canvas}.
|
|
72
|
-
* @param canvas The canvas to wrap.
|
|
73
|
-
* @param options The configuration for this canvas.
|
|
72
|
+
* @param canvas - The canvas to wrap.
|
|
73
|
+
* @param options - The configuration for this canvas.
|
|
74
74
|
*/
|
|
75
75
|
constructor(canvas, options = {}) {
|
|
76
76
|
this.#width = canvas.width;
|
|
@@ -120,7 +120,7 @@ export class Canvas {
|
|
|
120
120
|
/**
|
|
121
121
|
* Draws a slightly transparent, black rectangle over the canvas,
|
|
122
122
|
* and then reads the result back into the buffer.
|
|
123
|
-
* @param color The color to fade the buffer with. The alpha component of
|
|
123
|
+
* @param color - The color to fade the buffer with. The alpha component of
|
|
124
124
|
* the color defines how strong the fade is. `0` is not at all, `255` makes
|
|
125
125
|
* it instantly black.
|
|
126
126
|
*/
|
|
@@ -139,8 +139,8 @@ export class Canvas {
|
|
|
139
139
|
}
|
|
140
140
|
/**
|
|
141
141
|
* Returns the color of a pixel in the back buffer.
|
|
142
|
-
* @param x The X coordinate to retrieve.
|
|
143
|
-
* @param y The X coordinate to retrieve.
|
|
142
|
+
* @param x - The X coordinate to retrieve.
|
|
143
|
+
* @param y - The X coordinate to retrieve.
|
|
144
144
|
* @returns The color of the pixel at the given local.
|
|
145
145
|
*/
|
|
146
146
|
getPixel32(x, y) {
|
|
@@ -149,9 +149,9 @@ export class Canvas {
|
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
151
|
* Colors a pixel in the back buffer.
|
|
152
|
-
* @param x The X coordinate to color.
|
|
153
|
-
* @param y The Y coordinate to color.
|
|
154
|
-
* @param color The color to place at the coordinate.
|
|
152
|
+
* @param x - The X coordinate to color.
|
|
153
|
+
* @param y - The Y coordinate to color.
|
|
154
|
+
* @param color - The color to place at the coordinate.
|
|
155
155
|
*/
|
|
156
156
|
setPixel32(x, y, color) {
|
|
157
157
|
const bufferOffset = (x + y * this.#width) * 4;
|
|
@@ -162,7 +162,7 @@ export class Canvas {
|
|
|
162
162
|
}
|
|
163
163
|
/**
|
|
164
164
|
* Fills the entire back buffer with the given color.
|
|
165
|
-
* @param color The color to fill the back buffer with.
|
|
165
|
+
* @param color - The color to fill the back buffer with.
|
|
166
166
|
*/
|
|
167
167
|
clearWith(color) {
|
|
168
168
|
const r = getR(color);
|
|
@@ -178,7 +178,7 @@ export class Canvas {
|
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* Fills the entire back buffer with the given color.
|
|
181
|
-
* @param color The color to fill the back buffer with.
|
|
181
|
+
* @param color - The color to fill the back buffer with.
|
|
182
182
|
*/
|
|
183
183
|
blendWith(color) {
|
|
184
184
|
const r = getR(color);
|
|
@@ -204,11 +204,11 @@ export class Canvas {
|
|
|
204
204
|
*
|
|
205
205
|
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
206
206
|
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
207
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
208
|
-
* @param x The X coordinate at which to place the pixel.
|
|
209
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
210
|
-
* @param color The color of the pixel.
|
|
211
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
207
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
208
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
209
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
210
|
+
* @param color - The color of the pixel.
|
|
211
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
212
212
|
* @group Graphics
|
|
213
213
|
*/
|
|
214
214
|
export const putPixel32 = (canvas, x, y, color, alpha) => {
|
|
@@ -231,11 +231,11 @@ export const putPixel32 = (canvas, x, y, color, alpha) => {
|
|
|
231
231
|
*
|
|
232
232
|
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
233
233
|
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
234
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
235
|
-
* @param x The X coordinate at which to place the pixel.
|
|
236
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
237
|
-
* @param color The color of the pixel.
|
|
238
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
234
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
235
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
236
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
237
|
+
* @param color - The color of the pixel.
|
|
238
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
239
239
|
* @group Graphics
|
|
240
240
|
*/
|
|
241
241
|
export const putPixel32Add = (canvas, x, y, color, alpha) => {
|
|
@@ -258,11 +258,11 @@ export const putPixel32Add = (canvas, x, y, color, alpha) => {
|
|
|
258
258
|
*
|
|
259
259
|
* The `alpha` value is expected to be an integer in the range from `0` to `255`.
|
|
260
260
|
* `0` meaning fully transparent, `255` meaning fully opaque.
|
|
261
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
262
|
-
* @param x The X coordinate at which to place the pixel.
|
|
263
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
264
|
-
* @param color The color of the pixel.
|
|
265
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
261
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
262
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
263
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
264
|
+
* @param color - The color of the pixel.
|
|
265
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
266
266
|
* @group Graphics
|
|
267
267
|
*/
|
|
268
268
|
export const putPixel32Sub = (canvas, x, y, color, alpha) => {
|
|
@@ -276,11 +276,11 @@ export const putPixel32Sub = (canvas, x, y, color, alpha) => {
|
|
|
276
276
|
/**
|
|
277
277
|
* Linearly blends a new pixel with an existing color value in a {@linkcode Canvas}.
|
|
278
278
|
* Compared to {@linkcode putPixel32}, this function supports sub-pixel placement, but is dramatically slower.
|
|
279
|
-
* @param canvas The {@linkcode Canvas} to interact with.
|
|
280
|
-
* @param x The X coordinate at which to place the pixel.
|
|
281
|
-
* @param y The Y coordinate at which to place the pixel.
|
|
282
|
-
* @param color The color of the pixel.
|
|
283
|
-
* @param alpha The alpha value to use to blend the pixel with existing color at the location.
|
|
279
|
+
* @param canvas - The {@linkcode Canvas} to interact with.
|
|
280
|
+
* @param x - The X coordinate at which to place the pixel.
|
|
281
|
+
* @param y - The Y coordinate at which to place the pixel.
|
|
282
|
+
* @param color - The color of the pixel.
|
|
283
|
+
* @param alpha - The alpha value to use to blend the pixel with existing color at the location.
|
|
284
284
|
* @group Graphics
|
|
285
285
|
*/
|
|
286
286
|
export const putSubPixel32 = (canvas, x, y, color, alpha) => {
|
|
@@ -11,17 +11,17 @@ export declare const GOLDEN_RATIO = 1.618033988749;
|
|
|
11
11
|
export declare const PALETTES: number[][];
|
|
12
12
|
/**
|
|
13
13
|
* Constrains a color component value to single-byte range (`0`-`255`).
|
|
14
|
-
* @param c A color component value.
|
|
14
|
+
* @param c - A color component value.
|
|
15
15
|
* @returns The input value constrained into single-byte range.
|
|
16
16
|
* @group Graphics
|
|
17
17
|
*/
|
|
18
18
|
export declare const safeRGBComponent: (c: number) => number;
|
|
19
19
|
/**
|
|
20
20
|
* Constructs a 32bit integer value that represents an RGBA color value.
|
|
21
|
-
* @param r The R component.
|
|
22
|
-
* @param g The G component.
|
|
23
|
-
* @param b The B component.
|
|
24
|
-
* @param a The A component.
|
|
21
|
+
* @param r - The R component.
|
|
22
|
+
* @param g - The G component.
|
|
23
|
+
* @param b - The B component.
|
|
24
|
+
* @param a - The A component.
|
|
25
25
|
* @returns The constructed color value.
|
|
26
26
|
* @group Graphics
|
|
27
27
|
*/
|
|
@@ -29,37 +29,37 @@ export declare const fromRGBA: (r: number, g: number, b: number, a: number) => n
|
|
|
29
29
|
/**
|
|
30
30
|
* Constructs a 32bit integer value that represents an RGBA color value.
|
|
31
31
|
* The A component is fixed to `255`
|
|
32
|
-
* @param r The R component.
|
|
33
|
-
* @param g The G component.
|
|
34
|
-
* @param b The B component.
|
|
32
|
+
* @param r - The R component.
|
|
33
|
+
* @param g - The G component.
|
|
34
|
+
* @param b - The B component.
|
|
35
35
|
* @returns The constructed color value.
|
|
36
36
|
* @group Graphics
|
|
37
37
|
*/
|
|
38
38
|
export declare const fromRGB: (r: number, g: number, b: number) => number;
|
|
39
39
|
/**
|
|
40
40
|
* Extracts the R component from a color value.
|
|
41
|
-
* @param color The color value.
|
|
41
|
+
* @param color - The color value.
|
|
42
42
|
* @returns The R component of the color value.
|
|
43
43
|
* @group Graphics
|
|
44
44
|
*/
|
|
45
45
|
export declare const getR: (color: number) => number;
|
|
46
46
|
/**
|
|
47
47
|
* Extracts the G component from a color value.
|
|
48
|
-
* @param color The color value.
|
|
48
|
+
* @param color - The color value.
|
|
49
49
|
* @returns The G component of the color value.
|
|
50
50
|
* @group Graphics
|
|
51
51
|
*/
|
|
52
52
|
export declare const getG: (color: number) => number;
|
|
53
53
|
/**
|
|
54
54
|
* Extracts the B component from a color value.
|
|
55
|
-
* @param color The color value.
|
|
55
|
+
* @param color - The color value.
|
|
56
56
|
* @returns The B component of the color value.
|
|
57
57
|
* @group Graphics
|
|
58
58
|
*/
|
|
59
59
|
export declare const getB: (color: number) => number;
|
|
60
60
|
/**
|
|
61
61
|
* Extracts the A component from a color value.
|
|
62
|
-
* @param color The color value.
|
|
62
|
+
* @param color - The color value.
|
|
63
63
|
* @returns The A component of the color value.
|
|
64
64
|
* @group Graphics
|
|
65
65
|
*/
|
|
@@ -68,9 +68,9 @@ export declare const getA: (color: number) => number;
|
|
|
68
68
|
* Returns a new color that is a blend between a source and a destination
|
|
69
69
|
* color linerally. The alpha component in these colors is ignored. Instead, the provided
|
|
70
70
|
* `alpha` value is used to blend between the two colors.
|
|
71
|
-
* @param src The source color.
|
|
72
|
-
* @param dst The destination color.
|
|
73
|
-
* @param alpha The alpha value to use for blending.
|
|
71
|
+
* @param src - The source color.
|
|
72
|
+
* @param dst - The destination color.
|
|
73
|
+
* @param alpha - The alpha value to use for blending.
|
|
74
74
|
* @returns The blended color.
|
|
75
75
|
* @group Graphics
|
|
76
76
|
*/
|
|
@@ -79,9 +79,9 @@ export declare const blend: (src: number, dst: number, alpha: number) => number;
|
|
|
79
79
|
* Returns a new color that is a blend between a source and a destination
|
|
80
80
|
* color additively. The alpha component in these colors is ignored. Instead, the provided
|
|
81
81
|
* `alpha` value is used to blend between the two colors.
|
|
82
|
-
* @param src The source color.
|
|
83
|
-
* @param dst The destination color.
|
|
84
|
-
* @param alpha The alpha value to use for blending.
|
|
82
|
+
* @param src - The source color.
|
|
83
|
+
* @param dst - The destination color.
|
|
84
|
+
* @param alpha - The alpha value to use for blending.
|
|
85
85
|
* @returns The blended color.
|
|
86
86
|
* @group Graphics
|
|
87
87
|
*/
|
|
@@ -90,9 +90,9 @@ export declare const blendAdditive: (src: number, dst: number, alpha: number) =>
|
|
|
90
90
|
* Returns a new color that is a blend between a source and a destination
|
|
91
91
|
* color subtractively. The alpha component in these colors is ignored. Instead, the provided
|
|
92
92
|
* `alpha` value is used to blend between the two colors.
|
|
93
|
-
* @param src The source color.
|
|
94
|
-
* @param dst The destination color.
|
|
95
|
-
* @param alpha The alpha value to use for blending.
|
|
93
|
+
* @param src - The source color.
|
|
94
|
+
* @param dst - The destination color.
|
|
95
|
+
* @param alpha - The alpha value to use for blending.
|
|
96
96
|
* @returns The blended color.
|
|
97
97
|
* @group Graphics
|
|
98
98
|
*/
|
|
@@ -103,7 +103,7 @@ export declare const blendSubtractive: (src: number, dst: number, alpha: number)
|
|
|
103
103
|
* @returns A random color.
|
|
104
104
|
* @group Graphics
|
|
105
105
|
*/
|
|
106
|
-
export declare const
|
|
106
|
+
export declare const someColor: () => number;
|
|
107
107
|
/**
|
|
108
108
|
* Switches the global palette to the next available preset.
|
|
109
109
|
* @returns The new new global palette.
|
|
@@ -112,7 +112,7 @@ export declare const somecolor: () => number;
|
|
|
112
112
|
export declare const nextPalette: () => number[];
|
|
113
113
|
/**
|
|
114
114
|
* Converts a color value to grayscale.
|
|
115
|
-
* @param color The color to convert.
|
|
115
|
+
* @param color - The color to convert.
|
|
116
116
|
* @returns The grayscale value appropriate for the color.
|
|
117
117
|
* @group Graphics
|
|
118
118
|
*/
|
|
@@ -330,7 +330,7 @@ export const PALETTES = [
|
|
|
330
330
|
];
|
|
331
331
|
/**
|
|
332
332
|
* Constrains a color component value to single-byte range (`0`-`255`).
|
|
333
|
-
* @param c A color component value.
|
|
333
|
+
* @param c - A color component value.
|
|
334
334
|
* @returns The input value constrained into single-byte range.
|
|
335
335
|
* @group Graphics
|
|
336
336
|
*/
|
|
@@ -345,10 +345,10 @@ export const safeRGBComponent = (c) => {
|
|
|
345
345
|
};
|
|
346
346
|
/**
|
|
347
347
|
* Constructs a 32bit integer value that represents an RGBA color value.
|
|
348
|
-
* @param r The R component.
|
|
349
|
-
* @param g The G component.
|
|
350
|
-
* @param b The B component.
|
|
351
|
-
* @param a The A component.
|
|
348
|
+
* @param r - The R component.
|
|
349
|
+
* @param g - The G component.
|
|
350
|
+
* @param b - The B component.
|
|
351
|
+
* @param a - The A component.
|
|
352
352
|
* @returns The constructed color value.
|
|
353
353
|
* @group Graphics
|
|
354
354
|
*/
|
|
@@ -362,9 +362,9 @@ export const fromRGBA = (r, g, b, a) => {
|
|
|
362
362
|
/**
|
|
363
363
|
* Constructs a 32bit integer value that represents an RGBA color value.
|
|
364
364
|
* The A component is fixed to `255`
|
|
365
|
-
* @param r The R component.
|
|
366
|
-
* @param g The G component.
|
|
367
|
-
* @param b The B component.
|
|
365
|
+
* @param r - The R component.
|
|
366
|
+
* @param g - The G component.
|
|
367
|
+
* @param b - The B component.
|
|
368
368
|
* @returns The constructed color value.
|
|
369
369
|
* @group Graphics
|
|
370
370
|
*/
|
|
@@ -373,7 +373,7 @@ export const fromRGB = (r, g, b) => {
|
|
|
373
373
|
};
|
|
374
374
|
/**
|
|
375
375
|
* Extracts the R component from a color value.
|
|
376
|
-
* @param color The color value.
|
|
376
|
+
* @param color - The color value.
|
|
377
377
|
* @returns The R component of the color value.
|
|
378
378
|
* @group Graphics
|
|
379
379
|
*/
|
|
@@ -382,7 +382,7 @@ export const getR = (color) => {
|
|
|
382
382
|
};
|
|
383
383
|
/**
|
|
384
384
|
* Extracts the G component from a color value.
|
|
385
|
-
* @param color The color value.
|
|
385
|
+
* @param color - The color value.
|
|
386
386
|
* @returns The G component of the color value.
|
|
387
387
|
* @group Graphics
|
|
388
388
|
*/
|
|
@@ -391,7 +391,7 @@ export const getG = (color) => {
|
|
|
391
391
|
};
|
|
392
392
|
/**
|
|
393
393
|
* Extracts the B component from a color value.
|
|
394
|
-
* @param color The color value.
|
|
394
|
+
* @param color - The color value.
|
|
395
395
|
* @returns The B component of the color value.
|
|
396
396
|
* @group Graphics
|
|
397
397
|
*/
|
|
@@ -400,7 +400,7 @@ export const getB = (color) => {
|
|
|
400
400
|
};
|
|
401
401
|
/**
|
|
402
402
|
* Extracts the A component from a color value.
|
|
403
|
-
* @param color The color value.
|
|
403
|
+
* @param color - The color value.
|
|
404
404
|
* @returns The A component of the color value.
|
|
405
405
|
* @group Graphics
|
|
406
406
|
*/
|
|
@@ -411,9 +411,9 @@ export const getA = (color) => {
|
|
|
411
411
|
* Returns a new color that is a blend between a source and a destination
|
|
412
412
|
* color linerally. The alpha component in these colors is ignored. Instead, the provided
|
|
413
413
|
* `alpha` value is used to blend between the two colors.
|
|
414
|
-
* @param src The source color.
|
|
415
|
-
* @param dst The destination color.
|
|
416
|
-
* @param alpha The alpha value to use for blending.
|
|
414
|
+
* @param src - The source color.
|
|
415
|
+
* @param dst - The destination color.
|
|
416
|
+
* @param alpha - The alpha value to use for blending.
|
|
417
417
|
* @returns The blended color.
|
|
418
418
|
* @group Graphics
|
|
419
419
|
*/
|
|
@@ -432,9 +432,9 @@ export const blend = (src, dst, alpha) => {
|
|
|
432
432
|
* Returns a new color that is a blend between a source and a destination
|
|
433
433
|
* color additively. The alpha component in these colors is ignored. Instead, the provided
|
|
434
434
|
* `alpha` value is used to blend between the two colors.
|
|
435
|
-
* @param src The source color.
|
|
436
|
-
* @param dst The destination color.
|
|
437
|
-
* @param alpha The alpha value to use for blending.
|
|
435
|
+
* @param src - The source color.
|
|
436
|
+
* @param dst - The destination color.
|
|
437
|
+
* @param alpha - The alpha value to use for blending.
|
|
438
438
|
* @returns The blended color.
|
|
439
439
|
* @group Graphics
|
|
440
440
|
*/
|
|
@@ -451,9 +451,9 @@ export const blendAdditive = (src, dst, alpha) => {
|
|
|
451
451
|
* Returns a new color that is a blend between a source and a destination
|
|
452
452
|
* color subtractively. The alpha component in these colors is ignored. Instead, the provided
|
|
453
453
|
* `alpha` value is used to blend between the two colors.
|
|
454
|
-
* @param src The source color.
|
|
455
|
-
* @param dst The destination color.
|
|
456
|
-
* @param alpha The alpha value to use for blending.
|
|
454
|
+
* @param src - The source color.
|
|
455
|
+
* @param dst - The destination color.
|
|
456
|
+
* @param alpha - The alpha value to use for blending.
|
|
457
457
|
* @returns The blended color.
|
|
458
458
|
* @group Graphics
|
|
459
459
|
*/
|
|
@@ -475,8 +475,7 @@ export const blendSubtractive = (src, dst, alpha) => {
|
|
|
475
475
|
* @returns A random color.
|
|
476
476
|
* @group Graphics
|
|
477
477
|
*/
|
|
478
|
-
export const
|
|
479
|
-
// pick some random good color
|
|
478
|
+
export const someColor = () => {
|
|
480
479
|
const color = PALETTES[PALETTE_INDEX][Math.trunc(random.nextFloat() * PALETTES[PALETTE_INDEX].length)];
|
|
481
480
|
return (color << 8) | 0xff;
|
|
482
481
|
};
|
|
@@ -494,7 +493,7 @@ export const nextPalette = () => {
|
|
|
494
493
|
};
|
|
495
494
|
/**
|
|
496
495
|
* Converts a color value to grayscale.
|
|
497
|
-
* @param color The color to convert.
|
|
496
|
+
* @param color - The color to convert.
|
|
498
497
|
* @returns The grayscale value appropriate for the color.
|
|
499
498
|
* @group Graphics
|
|
500
499
|
*/
|