@oliversalzburg/js-utils 0.6.0 → 0.7.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.
Files changed (172) hide show
  1. package/package.json +5 -5
  2. package/lib/async/async.d.ts +0 -44
  3. package/lib/async/async.js +0 -76
  4. package/lib/async/async.js.map +0 -1
  5. package/lib/async/async.test.d.ts +0 -1
  6. package/lib/async/async.test.js +0 -26
  7. package/lib/async/async.test.js.map +0 -1
  8. package/lib/core.d.ts +0 -43
  9. package/lib/core.js +0 -2
  10. package/lib/core.js.map +0 -1
  11. package/lib/data/array.d.ts +0 -45
  12. package/lib/data/array.js +0 -70
  13. package/lib/data/array.js.map +0 -1
  14. package/lib/data/nil.d.ts +0 -92
  15. package/lib/data/nil.js +0 -131
  16. package/lib/data/nil.js.map +0 -1
  17. package/lib/data/random.d.ts +0 -111
  18. package/lib/data/random.js +0 -377
  19. package/lib/data/random.js.map +0 -1
  20. package/lib/data/string.d.ts +0 -30
  21. package/lib/data/string.js +0 -52
  22. package/lib/data/string.js.map +0 -1
  23. package/lib/data/tree.d.ts +0 -28
  24. package/lib/data/tree.js +0 -45
  25. package/lib/data/tree.js.map +0 -1
  26. package/lib/device/shake.d.ts +0 -79
  27. package/lib/device/shake.js +0 -135
  28. package/lib/device/shake.js.map +0 -1
  29. package/lib/dom/core.d.ts +0 -21
  30. package/lib/dom/core.js +0 -41
  31. package/lib/dom/core.js.map +0 -1
  32. package/lib/errors/AbstractError.d.ts +0 -29
  33. package/lib/errors/AbstractError.js +0 -59
  34. package/lib/errors/AbstractError.js.map +0 -1
  35. package/lib/errors/InternalError.d.ts +0 -19
  36. package/lib/errors/InternalError.js +0 -38
  37. package/lib/errors/InternalError.js.map +0 -1
  38. package/lib/errors/InvalidArgumentError.d.ts +0 -13
  39. package/lib/errors/InvalidArgumentError.js +0 -22
  40. package/lib/errors/InvalidArgumentError.js.map +0 -1
  41. package/lib/errors/InvalidOperationError.d.ts +0 -13
  42. package/lib/errors/InvalidOperationError.js +0 -22
  43. package/lib/errors/InvalidOperationError.js.map +0 -1
  44. package/lib/errors/NotImplementedError.d.ts +0 -12
  45. package/lib/errors/NotImplementedError.js +0 -21
  46. package/lib/errors/NotImplementedError.js.map +0 -1
  47. package/lib/errors/PermissionViolationError.d.ts +0 -13
  48. package/lib/errors/PermissionViolationError.js +0 -22
  49. package/lib/errors/PermissionViolationError.js.map +0 -1
  50. package/lib/errors/ResourceConflictError.d.ts +0 -12
  51. package/lib/errors/ResourceConflictError.js +0 -21
  52. package/lib/errors/ResourceConflictError.js.map +0 -1
  53. package/lib/errors/UnknownError.d.ts +0 -16
  54. package/lib/errors/UnknownError.js +0 -25
  55. package/lib/errors/UnknownError.js.map +0 -1
  56. package/lib/errors/console.d.ts +0 -7
  57. package/lib/errors/console.js +0 -13
  58. package/lib/errors/console.js.map +0 -1
  59. package/lib/errors/error-serializer.d.ts +0 -45
  60. package/lib/errors/error-serializer.js +0 -71
  61. package/lib/errors/error-serializer.js.map +0 -1
  62. package/lib/errors/error-serializer.test.d.ts +0 -1
  63. package/lib/errors/error-serializer.test.js +0 -109
  64. package/lib/errors/error-serializer.test.js.map +0 -1
  65. package/lib/errors/stream.d.ts +0 -7
  66. package/lib/errors/stream.js +0 -15
  67. package/lib/errors/stream.js.map +0 -1
  68. package/lib/errors/tools.d.ts +0 -10
  69. package/lib/errors/tools.js +0 -13
  70. package/lib/errors/tools.js.map +0 -1
  71. package/lib/events/event.d.ts +0 -9
  72. package/lib/events/event.js +0 -10
  73. package/lib/events/event.js.map +0 -1
  74. package/lib/format/bytes.d.ts +0 -118
  75. package/lib/format/bytes.js +0 -99
  76. package/lib/format/bytes.js.map +0 -1
  77. package/lib/format/bytes.test.d.ts +0 -1
  78. package/lib/format/bytes.test.js +0 -138
  79. package/lib/format/bytes.test.js.map +0 -1
  80. package/lib/format/count.d.ts +0 -14
  81. package/lib/format/count.js +0 -50
  82. package/lib/format/count.js.map +0 -1
  83. package/lib/format/count.test.d.ts +0 -1
  84. package/lib/format/count.test.js +0 -42
  85. package/lib/format/count.test.js.map +0 -1
  86. package/lib/format/milliseconds.d.ts +0 -100
  87. package/lib/format/milliseconds.js +0 -192
  88. package/lib/format/milliseconds.js.map +0 -1
  89. package/lib/format/milliseconds.test.d.ts +0 -1
  90. package/lib/format/milliseconds.test.js +0 -343
  91. package/lib/format/milliseconds.test.js.map +0 -1
  92. package/lib/format/string.d.ts +0 -24
  93. package/lib/format/string.js +0 -30
  94. package/lib/format/string.js.map +0 -1
  95. package/lib/format/string.test.d.ts +0 -1
  96. package/lib/format/string.test.js +0 -17
  97. package/lib/format/string.test.js.map +0 -1
  98. package/lib/graphics/canvas-sandbox-mp.d.ts +0 -258
  99. package/lib/graphics/canvas-sandbox-mp.js +0 -279
  100. package/lib/graphics/canvas-sandbox-mp.js.map +0 -1
  101. package/lib/graphics/canvas-sandbox.d.ts +0 -255
  102. package/lib/graphics/canvas-sandbox.js +0 -361
  103. package/lib/graphics/canvas-sandbox.js.map +0 -1
  104. package/lib/graphics/canvas.d.ts +0 -57
  105. package/lib/graphics/canvas.js +0 -37
  106. package/lib/graphics/canvas.js.map +0 -1
  107. package/lib/graphics/canvas2d-headless.d.ts +0 -85
  108. package/lib/graphics/canvas2d-headless.js +0 -193
  109. package/lib/graphics/canvas2d-headless.js.map +0 -1
  110. package/lib/graphics/canvas2d.d.ts +0 -162
  111. package/lib/graphics/canvas2d.js +0 -328
  112. package/lib/graphics/canvas2d.js.map +0 -1
  113. package/lib/graphics/canvas3d.d.ts +0 -41
  114. package/lib/graphics/canvas3d.js +0 -67
  115. package/lib/graphics/canvas3d.js.map +0 -1
  116. package/lib/graphics/color.d.ts +0 -22
  117. package/lib/graphics/color.js +0 -42
  118. package/lib/graphics/color.js.map +0 -1
  119. package/lib/graphics/core.d.ts +0 -89
  120. package/lib/graphics/core.js +0 -146
  121. package/lib/graphics/core.js.map +0 -1
  122. package/lib/graphics/palette-sampler.d.ts +0 -7
  123. package/lib/graphics/palette-sampler.js +0 -21
  124. package/lib/graphics/palette-sampler.js.map +0 -1
  125. package/lib/graphics/palette.d.ts +0 -120
  126. package/lib/graphics/palette.js +0 -494
  127. package/lib/graphics/palette.js.map +0 -1
  128. package/lib/graphics/palette.test.d.ts +0 -1
  129. package/lib/graphics/palette.test.js +0 -43
  130. package/lib/graphics/palette.test.js.map +0 -1
  131. package/lib/graphics/render-loop.d.ts +0 -80
  132. package/lib/graphics/render-loop.js +0 -120
  133. package/lib/graphics/render-loop.js.map +0 -1
  134. package/lib/graphics/shader.d.ts +0 -56
  135. package/lib/graphics/shader.js +0 -80
  136. package/lib/graphics/shader.js.map +0 -1
  137. package/lib/log/log.d.ts +0 -11
  138. package/lib/log/log.js +0 -2
  139. package/lib/log/log.js.map +0 -1
  140. package/lib/log/report.d.ts +0 -57
  141. package/lib/log/report.js +0 -88
  142. package/lib/log/report.js.map +0 -1
  143. package/lib/math/core.d.ts +0 -85
  144. package/lib/math/core.js +0 -125
  145. package/lib/math/core.js.map +0 -1
  146. package/lib/math/easing.d.ts +0 -204
  147. package/lib/math/easing.js +0 -332
  148. package/lib/math/easing.js.map +0 -1
  149. package/lib/math/euler.d.ts +0 -18
  150. package/lib/math/euler.js +0 -22
  151. package/lib/math/euler.js.map +0 -1
  152. package/lib/math/matrix3.d.ts +0 -217
  153. package/lib/math/matrix3.js +0 -508
  154. package/lib/math/matrix3.js.map +0 -1
  155. package/lib/math/quaternion.d.ts +0 -119
  156. package/lib/math/quaternion.js +0 -270
  157. package/lib/math/quaternion.js.map +0 -1
  158. package/lib/math/transformation.d.ts +0 -26
  159. package/lib/math/transformation.js +0 -31
  160. package/lib/math/transformation.js.map +0 -1
  161. package/lib/math/vector2.d.ts +0 -202
  162. package/lib/math/vector2.js +0 -310
  163. package/lib/math/vector2.js.map +0 -1
  164. package/lib/math/vector3.d.ts +0 -293
  165. package/lib/math/vector3.js +0 -492
  166. package/lib/math/vector3.js.map +0 -1
  167. package/lib/math/vector4.d.ts +0 -182
  168. package/lib/math/vector4.js +0 -302
  169. package/lib/math/vector4.js.map +0 -1
  170. package/lib/measurement/performance.d.ts +0 -13
  171. package/lib/measurement/performance.js +0 -19
  172. package/lib/measurement/performance.js.map +0 -1
@@ -1,146 +0,0 @@
1
- /**
2
- * The golden ratio.
3
- * @see {@link https://en.wikipedia.org/wiki/Golden_ratio}
4
- */
5
- export const GOLDEN_RATIO = 1.618033988749;
6
- /**
7
- * Constrains a color component value to single-byte range (`0`-`255`).
8
- * @param c - A color component value.
9
- * @returns The input value constrained into single-byte range.
10
- */
11
- export const safeRGBComponent = (c) => {
12
- if (c < 0) {
13
- c = 0;
14
- }
15
- if (255 < c) {
16
- c = 255;
17
- }
18
- return Math.trunc(c);
19
- };
20
- /**
21
- * Constructs a 32bit integer value that represents an RGBA color value.
22
- * @param r - The R component.
23
- * @param g - The G component.
24
- * @param b - The B component.
25
- * @param a - The A component.
26
- * @returns The constructed color value.
27
- */
28
- export const fromRGBA = (r, g, b, a) => {
29
- r = safeRGBComponent(r);
30
- g = safeRGBComponent(g);
31
- b = safeRGBComponent(b);
32
- a = safeRGBComponent(a);
33
- return (r << 24) | (g << 16) | (b << 8) | a;
34
- };
35
- /**
36
- * Constructs a 32bit integer value that represents an RGBA color value.
37
- * The A component is fixed to `255`
38
- * @param r - The R component.
39
- * @param g - The G component.
40
- * @param b - The B component.
41
- * @returns The constructed color value.
42
- */
43
- export const fromRGB = (r, g, b) => {
44
- return fromRGBA(r, g, b, 255);
45
- };
46
- /**
47
- * Extracts the R component from a color value.
48
- * @param color - The color value.
49
- * @returns The R component of the color value.
50
- */
51
- export const getR = (color) => {
52
- return (color >> 24) & 0xff;
53
- };
54
- /**
55
- * Extracts the G component from a color value.
56
- * @param color - The color value.
57
- * @returns The G component of the color value.
58
- */
59
- export const getG = (color) => {
60
- return (color >> 16) & 0xff;
61
- };
62
- /**
63
- * Extracts the B component from a color value.
64
- * @param color - The color value.
65
- * @returns The B component of the color value.
66
- */
67
- export const getB = (color) => {
68
- return (color >> 8) & 0xff;
69
- };
70
- /**
71
- * Extracts the A component from a color value.
72
- * @param color - The color value.
73
- * @returns The A component of the color value.
74
- */
75
- export const getA = (color) => {
76
- return color & 0xff;
77
- };
78
- /**
79
- * Returns a new color that is a blend between a source and a destination
80
- * color linerally. The alpha component in these colors is ignored. Instead, the provided
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.
85
- * @returns The blended color.
86
- */
87
- export const blend = (src, dst, alpha) => {
88
- if (alpha >= 255) {
89
- return dst;
90
- }
91
- if (alpha <= 0) {
92
- return src;
93
- }
94
- src |= 0;
95
- dst |= 0;
96
- return fromRGB((alpha * getR(dst) + (255 - alpha) * getR(src)) >> 8, (alpha * getG(dst) + (255 - alpha) * getG(src)) >> 8, (alpha * getB(dst) + (255 - alpha) * getB(src)) >> 8);
97
- };
98
- /**
99
- * Returns a new color that is a blend between a source and a destination
100
- * color additively. The alpha component in these colors is ignored. Instead, the provided
101
- * `alpha` value is used to blend between the two colors.
102
- * @param src - The source color.
103
- * @param dst - The destination color.
104
- * @param alpha - The alpha value to use for blending.
105
- * @returns The blended color.
106
- */
107
- export const blendAdditive = (src, dst, alpha) => {
108
- if (alpha >= 255) {
109
- return dst;
110
- }
111
- if (alpha <= 0) {
112
- return src;
113
- }
114
- return fromRGB(((alpha * getR(dst)) >> 8) + getR(src), ((alpha * getG(dst)) >> 8) + getG(src), ((alpha * getB(dst)) >> 8) + getB(src));
115
- };
116
- /**
117
- * Returns a new color that is a blend between a source and a destination
118
- * color subtractively. The alpha component in these colors is ignored. Instead, the provided
119
- * `alpha` value is used to blend between the two colors.
120
- * @param src - The source color.
121
- * @param dst - The destination color.
122
- * @param alpha - The alpha value to use for blending.
123
- * @returns The blended color.
124
- */
125
- export const blendSubtractive = (src, dst, alpha) => {
126
- if (alpha >= 255) {
127
- return dst;
128
- }
129
- if (alpha <= 0) {
130
- return src;
131
- }
132
- const r = getR(src) - ((alpha * getR(dst)) >> 8);
133
- const g = getG(src) - ((alpha * getG(dst)) >> 8);
134
- const b = getB(src) - ((alpha * getB(dst)) >> 8);
135
- return fromRGB(r < 0 ? 0 : r, g < 0 ? 0 : g, b < 0 ? 0 : b);
136
- };
137
- /**
138
- * Converts a color value to grayscale.
139
- * @param color - The color to convert.
140
- * @returns The grayscale value appropriate for the color.
141
- */
142
- export const toGrayScale = (color) => {
143
- const gs = getR(color) * 0.3 + getG(color) * 0.59 + getB(color) * 0.11;
144
- return fromRGBA(gs, gs, gs, getA(color));
145
- };
146
- //# sourceMappingURL=core.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../source/graphics/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAS,EAAE,EAAE;IAC5C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACV,CAAC,GAAG,CAAC,CAAC;IACR,CAAC;IACD,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;QACZ,CAAC,GAAG,GAAG,CAAC;IACV,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IACrE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAExB,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI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AAI,CAAC,EAAE,CAAC;QACf,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,OAAO,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE;IAC3C,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IACvE,OAAO,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { Palette } from "./palette.js";
2
- /**
3
- * Renders the colors of a palette into a canvas.
4
- * @param palette - The palette to render.
5
- * @param canvas - The canvas element to render to.
6
- */
7
- export declare const renderPaletteSample: (palette: Palette, canvas: HTMLCanvasElement | OffscreenCanvas) => void;
@@ -1,21 +0,0 @@
1
- import { mustExist } from "../data/nil.js";
2
- import { paletteName } from "./palette.js";
3
- /**
4
- * Renders the colors of a palette into a canvas.
5
- * @param palette - The palette to render.
6
- * @param canvas - The canvas element to render to.
7
- */
8
- export const renderPaletteSample = (palette, canvas) => {
9
- const context = mustExist(canvas.getContext("2d"));
10
- context.globalAlpha = 255;
11
- const step = canvas.width / palette.colors.length;
12
- for (let x = 0; x < palette.colors.length; ++x) {
13
- const fillColor = (palette.colors[x] << 8) | 0xff;
14
- context.fillStyle = `#${fillColor.toString(16).padStart(8, "0")}`;
15
- context.fillRect(x * step, 0, step, canvas.height);
16
- }
17
- context.font = "13px monospace";
18
- context.fillStyle = "#ffffffff";
19
- context.fillText(paletteName(palette.paletteIndex), 5, canvas.height * 0.8);
20
- };
21
- //# sourceMappingURL=palette-sampler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"palette-sampler.js","sourceRoot":"","sources":["../../source/graphics/palette-sampler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAW,WAAW,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,OAAgB,EAChB,MAA2C,EAC3C,EAAE;IACF,MAAM,OAAO,GAAG,SAAS,CACvB,MAAM,CAAC,UAAU,CAAC,IAAI,CAAwE,CAC/F,CAAC;IACF,OAAO,CAAC,WAAW,GAAG,GAAG,CAAC;IAE1B,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAC/C,MAAM,SAAS,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC;QAClD,OAAO,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;QAClE,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAChC,OAAO,CAAC,SAAS,GAAG,WAAW,CAAC;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AAC9E,CAAC,CAAC"}
@@ -1,120 +0,0 @@
1
- import { Random } from "../data/random.js";
2
- /**
3
- * Color palettes that can be used to quickly colorize a drawing.
4
- */
5
- export declare const PALETTES: number[][];
6
- /**
7
- * The indices of pre-defined palettes, with friendly names.
8
- * @see {@linkcode PALETTES}
9
- */
10
- export declare const NamedPalettes: {
11
- /**
12
- * ![Autumn lake colors](../../docs/media/palette-autumn-lake.png)
13
- */
14
- AutumnLake: number;
15
- /**
16
- * ![Camouflage colors](../../docs/media/palette-camouflage.png)
17
- */
18
- Camouflage: number;
19
- /**
20
- * ![Frog pond colors](../../docs/media/palette-frog-pond.png)
21
- */
22
- FrogPond: number;
23
- /**
24
- * ![Lillypads colors](../../docs/media/palette-lillypads.png)
25
- */
26
- Lillypads: number;
27
- /**
28
- * ![Midnight colors](../../docs/media/palette-midnight.png)
29
- */
30
- Midnight: number;
31
- /**
32
- * ![Plight colors](../../docs/media/palette-plight.png)
33
- */
34
- Plight: number;
35
- /**
36
- * ![Riverside colors](../../docs/media/palette-riverside.png)
37
- */
38
- Riverside: number;
39
- /**
40
- * ![Seaside colors](../../docs/media/palette-seaside.png)
41
- */
42
- Seaside: number;
43
- /**
44
- * ![Spring colors](../../docs/media/palette-spring.png)
45
- */
46
- Spring: number;
47
- /**
48
- * ![Sunflower field colors](../../docs/media/palette-sunflower-field.png)
49
- */
50
- SunflowerField: number;
51
- /**
52
- * ![Terminator colors](../../docs/media/palette-terminator.png)
53
- */
54
- Terminator: number;
55
- /**
56
- * ![Terra colors](../../docs/media/palette-terra.png)
57
- */
58
- Terra: number;
59
- /**
60
- * ![Tundra colors](../../docs/media/palette-tundra.png)
61
- */
62
- Tundra: number;
63
- };
64
- /**
65
- * Retrieves a friendly name for a pallete index.
66
- * @param paletteIndex - The index of the pre-defined palette.
67
- * @returns The friendly name of the palette, or `"<unknown>"`.
68
- */
69
- export declare const paletteName: (paletteIndex: number) => string;
70
- /**
71
- * Provides pre-defined color values for drawing operations.
72
- */
73
- export declare class Palette {
74
- #private;
75
- /**
76
- * Retrieve the index of the currently selected, pre-defined palette values.
77
- * @see {@linkcode PALETTES}
78
- * @returns The index of the currently selected, pre-defined palette values.
79
- */
80
- get paletteIndex(): number;
81
- /**
82
- * Retrieve the 24bit color values of the currently selected palette.
83
- * @returns The colors in the palette.
84
- */
85
- get colors(): ReadonlyArray<number>;
86
- /**
87
- * Constructs a new palette.
88
- * @param paletteIndex - The index of the pre-defined palette to use.
89
- */
90
- constructor(paletteIndex?: number);
91
- /**
92
- * Uses the next pre-defined color value set for this palette.
93
- * @returns This instance.
94
- */
95
- nextPalette(): this;
96
- /**
97
- * Retrieve a random color from the palette.
98
- * @param randomInstance - The PRNG to use. Ideally, supply your own.
99
- * @returns A random color from the palette.
100
- */
101
- someColor(randomInstance?: Random): number;
102
- }
103
- /**
104
- * A pre-constructed palette instance, for convenience.
105
- */
106
- export declare const palette: Palette;
107
- /**
108
- * Retrieves a random color from the current global palette.
109
- * Uses the global {@linkcode random} object.
110
- * @returns A random color.
111
- */
112
- export declare const someColor: () => number;
113
- /**
114
- * Switches the global palette to the next available preset.
115
- * @returns The new new global palette.
116
- * @deprecated Use {@linkcode Palette} instead.
117
- */
118
- export declare const nextPalette: () => number[];
119
- export declare const hslPalette: (entries: number, shift?: number, saturation?: number, luminance?: number) => Array<[number, number, number]>;
120
- export declare const hsvPalette: (entries: number, shift?: number, saturation?: number, value?: number) => Array<[number, number, number]>;