math 0.0.3 → 0.1.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 (203) hide show
  1. package/API.md +1605 -0
  2. package/LICENSE +21 -0
  3. package/README.md +197 -0
  4. package/dist/color/color.js +136 -0
  5. package/dist/color/color.js.map +1 -0
  6. package/dist/color/colorspace.js +43 -0
  7. package/dist/color/colorspace.js.map +1 -0
  8. package/dist/color/hsl.js +123 -0
  9. package/dist/color/hsl.js.map +1 -0
  10. package/dist/color/index.js +7 -0
  11. package/dist/color/index.js.map +1 -0
  12. package/dist/color/parse.js +276 -0
  13. package/dist/color/parse.js.map +1 -0
  14. package/dist/core/angle.js +43 -0
  15. package/dist/core/angle.js.map +1 -0
  16. package/dist/core/euler.js +212 -0
  17. package/dist/core/euler.js.map +1 -0
  18. package/dist/core/mat2.js +385 -0
  19. package/dist/core/mat2.js.map +1 -0
  20. package/dist/core/mat2d.js +422 -0
  21. package/dist/core/mat2d.js.map +1 -0
  22. package/dist/core/mat3.js +749 -0
  23. package/dist/core/mat3.js.map +1 -0
  24. package/dist/core/mat4.js +2197 -0
  25. package/dist/core/mat4.js.map +1 -0
  26. package/dist/core/polar.js +200 -0
  27. package/dist/core/polar.js.map +1 -0
  28. package/dist/core/quat.js +730 -0
  29. package/dist/core/quat.js.map +1 -0
  30. package/dist/core/quat2.js +883 -0
  31. package/dist/core/quat2.js.map +1 -0
  32. package/dist/core/scalar.js +112 -0
  33. package/dist/core/scalar.js.map +1 -0
  34. package/dist/core/spherical.js +248 -0
  35. package/dist/core/spherical.js.map +1 -0
  36. package/dist/core/vec2.js +597 -0
  37. package/dist/core/vec2.js.map +1 -0
  38. package/dist/core/vec3.js +916 -0
  39. package/dist/core/vec3.js.map +1 -0
  40. package/dist/core/vec4.js +573 -0
  41. package/dist/core/vec4.js.map +1 -0
  42. package/dist/geometry/circumcircle.js +39 -0
  43. package/dist/geometry/circumcircle.js.map +1 -0
  44. package/dist/geometry/index.js +6 -0
  45. package/dist/geometry/index.js.map +1 -0
  46. package/dist/geometry/polygon2-decompose.js +411 -0
  47. package/dist/geometry/polygon2-decompose.js.map +1 -0
  48. package/dist/geometry/polygon2-triangulate.js +222 -0
  49. package/dist/geometry/polygon2-triangulate.js.map +1 -0
  50. package/dist/geometry/quickhull2.js +123 -0
  51. package/dist/geometry/quickhull2.js.map +1 -0
  52. package/dist/geometry/quickhull3.js +605 -0
  53. package/dist/geometry/quickhull3.js.map +1 -0
  54. package/dist/ik/fabrik2.js +675 -0
  55. package/dist/ik/fabrik2.js.map +1 -0
  56. package/dist/ik/fabrik3.js +912 -0
  57. package/dist/ik/fabrik3.js.map +1 -0
  58. package/dist/ik/index.js +5 -0
  59. package/dist/ik/index.js.map +1 -0
  60. package/dist/index.js +27 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/noise/fractal.js +185 -0
  63. package/dist/noise/fractal.js.map +1 -0
  64. package/dist/noise/index.js +16 -0
  65. package/dist/noise/index.js.map +1 -0
  66. package/dist/noise/perlin2d.js +50 -0
  67. package/dist/noise/perlin2d.js.map +1 -0
  68. package/dist/noise/perlin3d.js +72 -0
  69. package/dist/noise/perlin3d.js.map +1 -0
  70. package/dist/noise/permutation.js +120 -0
  71. package/dist/noise/permutation.js.map +1 -0
  72. package/dist/noise/simplex2d.js +84 -0
  73. package/dist/noise/simplex2d.js.map +1 -0
  74. package/dist/noise/simplex3d.js +147 -0
  75. package/dist/noise/simplex3d.js.map +1 -0
  76. package/dist/noise/simplex4d.js +149 -0
  77. package/dist/noise/simplex4d.js.map +1 -0
  78. package/dist/noise/worley2d.js +50 -0
  79. package/dist/noise/worley2d.js.map +1 -0
  80. package/dist/noise/worley3d.js +61 -0
  81. package/dist/noise/worley3d.js.map +1 -0
  82. package/dist/random/index.js +9 -0
  83. package/dist/random/index.js.map +1 -0
  84. package/dist/random/isaac32.js +164 -0
  85. package/dist/random/isaac32.js.map +1 -0
  86. package/dist/random/isaac64.js +215 -0
  87. package/dist/random/isaac64.js.map +1 -0
  88. package/dist/random/mulberry32.js +48 -0
  89. package/dist/random/mulberry32.js.map +1 -0
  90. package/dist/random/random.js +120 -0
  91. package/dist/random/random.js.map +1 -0
  92. package/dist/shapes/box2.js +300 -0
  93. package/dist/shapes/box2.js.map +1 -0
  94. package/dist/shapes/box3.js +550 -0
  95. package/dist/shapes/box3.js.map +1 -0
  96. package/dist/shapes/circle.js +6 -0
  97. package/dist/shapes/circle.js.map +1 -0
  98. package/dist/shapes/frustum.js +662 -0
  99. package/dist/shapes/frustum.js.map +1 -0
  100. package/dist/shapes/index.js +25 -0
  101. package/dist/shapes/index.js.map +1 -0
  102. package/dist/shapes/obb3.js +557 -0
  103. package/dist/shapes/obb3.js.map +1 -0
  104. package/dist/shapes/plane3.js +267 -0
  105. package/dist/shapes/plane3.js.map +1 -0
  106. package/dist/shapes/polygon2.js +451 -0
  107. package/dist/shapes/polygon2.js.map +1 -0
  108. package/dist/shapes/raycast3.js +164 -0
  109. package/dist/shapes/raycast3.js.map +1 -0
  110. package/dist/shapes/segment2.js +82 -0
  111. package/dist/shapes/segment2.js.map +1 -0
  112. package/dist/shapes/sphere.js +23 -0
  113. package/dist/shapes/sphere.js.map +1 -0
  114. package/dist/shapes/triangle2.js +79 -0
  115. package/dist/shapes/triangle2.js.map +1 -0
  116. package/dist/shapes/triangle3.js +60 -0
  117. package/dist/shapes/triangle3.js.map +1 -0
  118. package/dist/src/color/color.d.ts +50 -0
  119. package/dist/src/color/colorspace.d.ts +15 -0
  120. package/dist/src/color/hsl.d.ts +28 -0
  121. package/dist/src/color/index.d.ts +5 -0
  122. package/dist/src/color/parse.d.ts +15 -0
  123. package/dist/src/core/angle.d.ts +29 -0
  124. package/dist/src/core/arrays.d.ts +4 -0
  125. package/dist/src/core/euler.d.ts +78 -0
  126. package/dist/src/core/index.d.ts +27 -0
  127. package/dist/src/core/mat2.d.ts +217 -0
  128. package/dist/src/core/mat2d.d.ts +218 -0
  129. package/dist/src/core/mat3.d.ts +295 -0
  130. package/dist/src/core/mat4.d.ts +667 -0
  131. package/dist/src/core/polar.d.ts +151 -0
  132. package/dist/src/core/quat.d.ts +370 -0
  133. package/dist/src/core/quat2.d.ts +344 -0
  134. package/dist/src/core/scalar.d.ts +75 -0
  135. package/dist/src/core/spherical.d.ts +165 -0
  136. package/dist/src/core/vec2.d.ts +403 -0
  137. package/dist/src/core/vec3.d.ts +493 -0
  138. package/dist/src/core/vec4.d.ts +336 -0
  139. package/dist/src/geometry/circumcircle.d.ts +9 -0
  140. package/dist/src/geometry/index.d.ts +5 -0
  141. package/dist/src/geometry/polygon2-decompose.d.ts +25 -0
  142. package/dist/src/geometry/polygon2-triangulate.d.ts +15 -0
  143. package/dist/src/geometry/quickhull2.d.ts +10 -0
  144. package/dist/src/geometry/quickhull3.d.ts +27 -0
  145. package/dist/src/ik/fabrik2.d.ts +314 -0
  146. package/dist/src/ik/fabrik3.d.ts +371 -0
  147. package/dist/src/ik/index.d.ts +2 -0
  148. package/dist/src/index.d.ts +1 -0
  149. package/dist/src/noise/fractal.d.ts +95 -0
  150. package/dist/src/noise/index.d.ts +9 -0
  151. package/dist/src/noise/perlin2d.d.ts +19 -0
  152. package/dist/src/noise/perlin3d.d.ts +20 -0
  153. package/dist/src/noise/permutation.d.ts +22 -0
  154. package/dist/src/noise/simplex2d.d.ts +19 -0
  155. package/dist/src/noise/simplex3d.d.ts +20 -0
  156. package/dist/src/noise/simplex4d.d.ts +24 -0
  157. package/dist/src/noise/worley2d.d.ts +22 -0
  158. package/dist/src/noise/worley3d.d.ts +23 -0
  159. package/dist/src/random/index.d.ts +8 -0
  160. package/dist/src/random/isaac32.d.ts +62 -0
  161. package/dist/src/random/isaac64.d.ts +75 -0
  162. package/dist/src/random/mulberry32.d.ts +43 -0
  163. package/dist/src/random/random.d.ts +67 -0
  164. package/dist/src/shapes/box2.d.ts +174 -0
  165. package/dist/src/shapes/box3.d.ts +213 -0
  166. package/dist/src/shapes/circle.d.ts +7 -0
  167. package/dist/src/shapes/frustum.d.ts +147 -0
  168. package/dist/src/shapes/index.d.ts +20 -0
  169. package/dist/src/shapes/obb3.d.ts +105 -0
  170. package/dist/src/shapes/plane3.d.ts +130 -0
  171. package/dist/src/shapes/polygon2.d.ts +155 -0
  172. package/dist/src/shapes/raycast3.d.ts +42 -0
  173. package/dist/src/shapes/segment2.d.ts +34 -0
  174. package/dist/src/shapes/sphere.d.ts +19 -0
  175. package/dist/src/shapes/triangle2.d.ts +53 -0
  176. package/dist/src/shapes/triangle3.d.ts +29 -0
  177. package/dist/src/time/easing.d.ts +21 -0
  178. package/dist/src/time/index.d.ts +6 -0
  179. package/dist/src/time/spring-core.d.ts +15 -0
  180. package/dist/src/time/spring.d.ts +36 -0
  181. package/dist/src/time/spring2.d.ts +11 -0
  182. package/dist/src/time/spring3.d.ts +11 -0
  183. package/dist/src/time/spring4.d.ts +11 -0
  184. package/dist/time/easing.js +24 -0
  185. package/dist/time/easing.js.map +1 -0
  186. package/dist/time/index.js +11 -0
  187. package/dist/time/index.js.map +1 -0
  188. package/dist/time/spring-core.js +48 -0
  189. package/dist/time/spring-core.js.map +1 -0
  190. package/dist/time/spring.js +62 -0
  191. package/dist/time/spring.js.map +1 -0
  192. package/dist/time/spring2.js +31 -0
  193. package/dist/time/spring2.js.map +1 -0
  194. package/dist/time/spring3.js +32 -0
  195. package/dist/time/spring3.js.map +1 -0
  196. package/dist/time/spring4.js +32 -0
  197. package/dist/time/spring4.js.map +1 -0
  198. package/package.json +90 -16
  199. package/skills/math/SKILL.md +140 -0
  200. package/AUTHORS +0 -1
  201. package/Cakefile +0 -28
  202. package/math.coffee +0 -112
  203. package/math.js +0 -141
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright © 2026 Isaac Mason
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
13
+ all 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
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # math
2
+
3
+ math is a collection of math helpers for graphics and simulations.
4
+
5
+ - **High performance**: allocation-free, monomorphic, benchmarked
6
+ - **Tiny**: mean and lean, tree-shakable, only pay for what you use
7
+ - **Portable**: interops with WebGL, WebGPU, Wasm, your favourite renderer, more.
8
+ - **Data-oriented**: data-in, data-out functions over caller-owned data, without owning the data lifecycle.
9
+
10
+ ```sh
11
+ > npm install math@canary
12
+ ```
13
+
14
+ ## What's inside
15
+
16
+ | Import | Description | Contents |
17
+ | --- | --- | --- |
18
+ | [`math`](API.md#api-math) | Vectors, quaternions, euler angles & matrices | [`vec2`](API.md#api-math-vec2) [`vec3`](API.md#api-math-vec3) [`vec4`](API.md#api-math-vec4) [`euler`](API.md#api-math-euler) [`quat`](API.md#api-math-quat) [`quat2`](API.md#api-math-quat2) [`mat2`](API.md#api-math-mat2) [`mat2d`](API.md#api-math-mat2d) [`mat3`](API.md#api-math-mat3) [`mat4`](API.md#api-math-mat4) [`spherical`](API.md#api-math-spherical) [`polar`](API.md#api-math-polar) [`EPSILON`](API.md#epsilon) [`round`](API.md#round) [`equals`](API.md#equals) [`fade`](API.md#fade) [`lerp`](API.md#lerp) [`lagrange`](API.md#lagrange) [`binomial`](API.md#binomial) [`clamp`](API.md#clamp) [`repeat`](API.md#repeat) [`remap`](API.md#remap) [`remapClamp`](API.md#remapclamp) [`DEGREES_TO_RADIANS`](API.md#degrees_to_radians) [`RADIANS_TO_DEGREES`](API.md#radians_to_degrees) [`degreesToRadians`](API.md#degreestoradians) [`radiansToDegrees`](API.md#radianstodegrees) [`wrapAngle`](API.md#wrapangle) [`deltaAngle`](API.md#deltaangle) |
19
+ | [`math/shapes`](API.md#api-math-shapes) | Shape primitives & spatial queries | [`box2`](API.md#api-math-shapes-box2) [`box3`](API.md#api-math-shapes-box3) [`obb3`](API.md#api-math-shapes-obb3) [`plane3`](API.md#api-math-shapes-plane3) [`sphere`](API.md#api-math-shapes-sphere) [`circle`](API.md#api-math-shapes-circle) [`segment2`](API.md#api-math-shapes-segment2) [`polygon2`](API.md#api-math-shapes-polygon2) [`triangle2`](API.md#api-math-shapes-triangle2) [`triangle3`](API.md#api-math-shapes-triangle3) [`raycast3`](API.md#api-math-shapes-raycast3) [`frustum`](API.md#api-math-shapes-frustum) |
20
+ | [`math/geometry`](API.md#api-math-geometry) | Geometric algorithms | [`circumcircle`](API.md#circumcircle) [`decomposePolygon2Quick`](API.md#decomposepolygon2quick) [`decomposePolygon2Quality`](API.md#decomposepolygon2quality) [`triangulatePolygon2`](API.md#triangulatepolygon2) [`quickhull2`](API.md#quickhull2) [`quickhull3`](API.md#quickhull3) |
21
+ | [`math/time`](API.md#api-math-time) | Easing & spring animation | [`easing`](API.md#api-math-time-easing) [`spring`](API.md#api-math-time-spring) [`spring2`](API.md#api-math-time-spring2) [`spring3`](API.md#api-math-time-spring3) [`spring4`](API.md#api-math-time-spring4) |
22
+ | [`math/random`](API.md#api-math-random) | Seeded random number generators | [`isaac32`](API.md#api-math-random-isaac32) [`isaac64`](API.md#api-math-random-isaac64) [`mulberry32`](API.md#api-math-random-mulberry32) [`random`](API.md#api-math-random-random) |
23
+ | [`math/noise`](API.md#api-math-noise) | Perlin, simplex & worley noise, plus fractal helpers | [`perlin2d`](API.md#api-math-noise-perlin2d) [`perlin3d`](API.md#api-math-noise-perlin3d) [`simplex2d`](API.md#api-math-noise-simplex2d) [`simplex3d`](API.md#api-math-noise-simplex3d) [`simplex4d`](API.md#api-math-noise-simplex4d) [`worley2d`](API.md#api-math-noise-worley2d) [`worley3d`](API.md#api-math-noise-worley3d) [`fbm`](API.md#fbm) [`ridged`](API.md#ridged) [`billow`](API.md#billow) [`domainWarp2`](API.md#domainwarp2) [`domainWarp3`](API.md#domainwarp3) [`curl2`](API.md#curl2) [`curl3`](API.md#curl3) |
24
+ | [`math/color`](API.md#api-math-color) | Color & colorspace utilities | [`color`](API.md#api-math-color-color) [`colorspace`](API.md#api-math-color-colorspace) [`hsl`](API.md#api-math-color-hsl) |
25
+ | [`math/ik`](API.md#api-math-ik) | Inverse kinematics | [`fabrik2`](API.md#api-math-ik-fabrik2) [`fabrik3`](API.md#api-math-ik-fabrik3) |
26
+
27
+
28
+ ## Quick Start
29
+
30
+ ```ts
31
+ import { type Vec3, vec3 } from 'math';
32
+
33
+ // math types are plain arrays — the constructors just return literals:
34
+ const a: Vec3 = [1, 2, 3]; // a plain-array literal
35
+ const b = vec3.fromValues(1, 2, 3); // the same as `a`
36
+ const out = vec3.create(); // returns [0, 0, 0]
37
+
38
+ // functions write into their first argument, so nothing is allocated:
39
+ vec3.add(out, a, b); // out = [2, 4, 6]
40
+ vec3.normalize(out, out); // aliasing an argument is fine
41
+ ```
42
+
43
+ The library is grouped by domain behind subpath entrypoints. All APIs are highly tree-shakeable, only pay for what you use:
44
+
45
+ ```ts
46
+ import { mat4, quat, vec3 } from 'math'; // core: vectors, quats, matrices
47
+ import { simplex3d } from 'math/noise'; // perlin / simplex noise
48
+ import { mulberry32 } from 'math/random'; // seeded rng
49
+ import { easing, spring } from 'math/time'; // easings & springs
50
+ import { fabrik2, fabrik3 } from 'math/ik'; // inverse kinematics
51
+ // also: math/color, math/geometry, math/shapes — import only what you use
52
+ ```
53
+
54
+ ## Examples
55
+
56
+ <table>
57
+ <tr>
58
+ <td align="center">
59
+ <a href="https://pmndrs.github.io/math/examples/#example-look-at">
60
+ <img src="./examples/public/screenshots/example-look-at.png" width="180" height="120" style="object-fit:cover;"/><br/>
61
+ Look At
62
+ </a>
63
+ </td>
64
+ <td align="center">
65
+ <a href="https://pmndrs.github.io/math/examples/#example-fibonacci-sphere">
66
+ <img src="./examples/public/screenshots/example-fibonacci-sphere.png" width="180" height="120" style="object-fit:cover;"/><br/>
67
+ Fibonacci Sphere
68
+ </a>
69
+ </td>
70
+ <td align="center">
71
+ <a href="https://pmndrs.github.io/math/examples/#example-contains-point">
72
+ <img src="./examples/public/screenshots/example-contains-point.png" width="180" height="120" style="object-fit:cover;"/><br/>
73
+ Contains Point
74
+ </a>
75
+ </td>
76
+ </tr>
77
+ <tr>
78
+ <td align="center">
79
+ <a href="https://pmndrs.github.io/math/examples/#example-convex-hull-3d">
80
+ <img src="./examples/public/screenshots/example-convex-hull-3d.png" width="180" height="120" style="object-fit:cover;"/><br/>
81
+ Convex Hull 3D
82
+ </a>
83
+ </td>
84
+ <td align="center">
85
+ <a href="https://pmndrs.github.io/math/examples/#example-convex-hull-2d">
86
+ <img src="./examples/public/screenshots/example-convex-hull-2d.png" width="180" height="120" style="object-fit:cover;"/><br/>
87
+ Convex Hull 2D
88
+ </a>
89
+ </td>
90
+ <td align="center">
91
+ <a href="https://pmndrs.github.io/math/examples/#example-polygon2-decomposition">
92
+ <img src="./examples/public/screenshots/example-polygon2-decomposition.png" width="180" height="120" style="object-fit:cover;"/><br/>
93
+ Polygon2 Decomposition
94
+ </a>
95
+ </td>
96
+ </tr>
97
+ <tr>
98
+ <td align="center">
99
+ <a href="https://pmndrs.github.io/math/examples/#example-polygon2-triangulation">
100
+ <img src="./examples/public/screenshots/example-polygon2-triangulation.png" width="180" height="120" style="object-fit:cover;"/><br/>
101
+ Polygon2 Triangulation
102
+ </a>
103
+ </td>
104
+ <td align="center">
105
+ <a href="https://pmndrs.github.io/math/examples/#example-circumcircle">
106
+ <img src="./examples/public/screenshots/example-circumcircle.png" width="180" height="120" style="object-fit:cover;"/><br/>
107
+ Circumcircle
108
+ </a>
109
+ </td>
110
+ <td align="center">
111
+ <a href="https://pmndrs.github.io/math/examples/#example-fabrik-2d">
112
+ <img src="./examples/public/screenshots/example-fabrik-2d.png" width="180" height="120" style="object-fit:cover;"/><br/>
113
+ FABRIK 2D
114
+ </a>
115
+ </td>
116
+ </tr>
117
+ <tr>
118
+ <td align="center">
119
+ <a href="https://pmndrs.github.io/math/examples/#example-fabrik-2d-snek">
120
+ <img src="./examples/public/screenshots/example-fabrik-2d-snek.png" width="180" height="120" style="object-fit:cover;"/><br/>
121
+ FABRIK 2D Snek
122
+ </a>
123
+ </td>
124
+ <td align="center">
125
+ <a href="https://pmndrs.github.io/math/examples/#example-fabrik-3d">
126
+ <img src="./examples/public/screenshots/example-fabrik-3d.png" width="180" height="120" style="object-fit:cover;"/><br/>
127
+ FABRIK 3D
128
+ </a>
129
+ </td>
130
+ <td align="center">
131
+ <a href="https://pmndrs.github.io/math/examples/#example-flow-field">
132
+ <img src="./examples/public/screenshots/example-flow-field.png" width="180" height="120" style="object-fit:cover;"/><br/>
133
+ Flow Field
134
+ </a>
135
+ </td>
136
+ </tr>
137
+ <tr>
138
+ <td align="center">
139
+ <a href="https://pmndrs.github.io/math/examples/#example-color-wheel">
140
+ <img src="./examples/public/screenshots/example-color-wheel.png" width="180" height="120" style="object-fit:cover;"/><br/>
141
+ Color Wheel
142
+ </a>
143
+ </td>
144
+ <td align="center">
145
+ <a href="https://pmndrs.github.io/math/examples/#example-ridged-noise-voxel-terrain">
146
+ <img src="./examples/public/screenshots/example-ridged-noise-voxel-terrain.png" width="180" height="120" style="object-fit:cover;"/><br/>
147
+ Ridged Noise Voxel Terrain
148
+ </a>
149
+ </td>
150
+ <td align="center">
151
+ <a href="https://pmndrs.github.io/math/examples/#example-simplex-4d-looping-noise">
152
+ <img src="./examples/public/screenshots/example-simplex-4d-looping-noise.png" width="180" height="120" style="object-fit:cover;"/><br/>
153
+ Simplex 4D Looping Noise
154
+ </a>
155
+ </td>
156
+ </tr>
157
+ <tr>
158
+ <td align="center">
159
+ <a href="https://pmndrs.github.io/math/examples/#example-simplex-2d-noise-terrain">
160
+ <img src="./examples/public/screenshots/example-simplex-2d-noise-terrain.png" width="180" height="120" style="object-fit:cover;"/><br/>
161
+ Simplex 2D Noise Terrain
162
+ </a>
163
+ </td>
164
+ <td align="center">
165
+ <a href="https://pmndrs.github.io/math/examples/#example-quaternion-slerp">
166
+ <img src="./examples/public/screenshots/example-quaternion-slerp.png" width="180" height="120" style="object-fit:cover;"/><br/>
167
+ Quaternion Slerp
168
+ </a>
169
+ </td>
170
+ <td align="center">
171
+ <a href="https://pmndrs.github.io/math/examples/#example-spring">
172
+ <img src="./examples/public/screenshots/example-spring.png" width="180" height="120" style="object-fit:cover;"/><br/>
173
+ Spring
174
+ </a>
175
+ </td>
176
+ </tr>
177
+ <tr>
178
+ <td align="center">
179
+ <a href="https://pmndrs.github.io/math/examples/#example-easing">
180
+ <img src="./examples/public/screenshots/example-easing.png" width="180" height="120" style="object-fit:cover;"/><br/>
181
+ Easing
182
+ </a>
183
+ </td>
184
+ </tr>
185
+ </table>
186
+
187
+ ## Documentation
188
+
189
+ - **[API.md](./API.md)** — every export with its signature and a one-line description, grouped by module. Flat and greppable, so it's easy to search or hand to an AI coding assistant.
190
+ - **[Online API docs](https://pmndrs.github.io/math/docs/)** — the full typedoc reference, with search and cross-links.
191
+ - **[What's inside](#whats-inside)** — jump straight to a module or namespace.
192
+
193
+ ## Acknowledgements:
194
+
195
+ - The vec*, quat*, mat* code started life as a port of mathcat, which started as a TypeScript port of glMatrix (https://glmatrix.net/)
196
+ - The simplex noise is adapted from https://github.com/josephg/noisejs
197
+ - Thank you [@kaleb](https://github.com/kaleb) for the npm package name!
@@ -0,0 +1,136 @@
1
+ import { srgbToLinear, linearToSrgb } from './colorspace.js';
2
+ export { fromColorInput, setFromColorInput } from './parse.js';
3
+
4
+ /** Create a new Color initialized to black [0, 0, 0]. */
5
+ function create() {
6
+ return [0, 0, 0];
7
+ }
8
+ /** Create a new Color with the given linear r, g, b values. */
9
+ function fromValues(r, g, b) {
10
+ return [r, g, b];
11
+ }
12
+ /** Create a new Color that is a copy of `c`. */
13
+ function clone(c) {
14
+ return [c[0], c[1], c[2]];
15
+ }
16
+ /** Copy the values from `src` into `out`. Returns `out`. */
17
+ function copy(out, src) {
18
+ out[0] = src[0];
19
+ out[1] = src[1];
20
+ out[2] = src[2];
21
+ return out;
22
+ }
23
+ /** Set the linear r, g, b components of `out` directly. Returns `out`. */
24
+ function set(out, r, g, b) {
25
+ out[0] = r;
26
+ out[1] = g;
27
+ out[2] = b;
28
+ return out;
29
+ }
30
+ /** Set all three channels of `out` to the same linear value `s` (a gray). Returns `out`. */
31
+ function setScalar(out, s) {
32
+ out[0] = s;
33
+ out[1] = s;
34
+ out[2] = s;
35
+ return out;
36
+ }
37
+ /**
38
+ * Set `out` from an sRGB gamma-encoded [r, g, b] array with values in [0, 1].
39
+ * Converts from sRGB gamma space to linear. Returns `out`.
40
+ */
41
+ function setFromSRGB(out, srgb) {
42
+ out[0] = srgbToLinear(srgb[0]);
43
+ out[1] = srgbToLinear(srgb[1]);
44
+ out[2] = srgbToLinear(srgb[2]);
45
+ return out;
46
+ }
47
+ /** Create a new Color from an sRGB gamma-encoded [r, g, b] array with values in [0, 1]. */
48
+ function fromSRGB(srgb) {
49
+ return setFromSRGB(create(), srgb);
50
+ }
51
+ /** Write the sRGB gamma-encoded [r, g, b] of a linear Color into `out` (values [0, 1]). */
52
+ function toSRGB(out, c) {
53
+ out[0] = linearToSrgb(c[0]);
54
+ out[1] = linearToSrgb(c[1]);
55
+ out[2] = linearToSrgb(c[2]);
56
+ return out;
57
+ }
58
+ /** Create a CSS `rgb(...)` string in sRGB gamma space (for HTML/canvas use). */
59
+ function toCSS(c) {
60
+ return `rgb(${to255(c[0])}, ${to255(c[1])}, ${to255(c[2])})`;
61
+ }
62
+ /** Convert to a 0xRRGGBB integer in sRGB gamma space. */
63
+ function toHex(c) {
64
+ return (to255(c[0]) << 16) | (to255(c[1]) << 8) | to255(c[2]);
65
+ }
66
+ /** Convert to a 6-digit sRGB hex string without a leading '#', e.g. 'ff8800'. */
67
+ function toHexString(c) {
68
+ return toHex(c).toString(16).padStart(6, '0');
69
+ }
70
+ /** Add `a + b` component-wise into `out`. Returns `out`. */
71
+ function add(out, a, b) {
72
+ out[0] = a[0] + b[0];
73
+ out[1] = a[1] + b[1];
74
+ out[2] = a[2] + b[2];
75
+ return out;
76
+ }
77
+ /** Add scalar `s` to each channel of `a` into `out`. Returns `out`. */
78
+ function addScalar(out, a, s) {
79
+ out[0] = a[0] + s;
80
+ out[1] = a[1] + s;
81
+ out[2] = a[2] + s;
82
+ return out;
83
+ }
84
+ /** Subtract `a - b` component-wise into `out`. Returns `out`. */
85
+ function sub(out, a, b) {
86
+ out[0] = a[0] - b[0];
87
+ out[1] = a[1] - b[1];
88
+ out[2] = a[2] - b[2];
89
+ return out;
90
+ }
91
+ /** Multiply `a * b` component-wise into `out` (tinting). Returns `out`. */
92
+ function multiply(out, a, b) {
93
+ out[0] = a[0] * b[0];
94
+ out[1] = a[1] * b[1];
95
+ out[2] = a[2] * b[2];
96
+ return out;
97
+ }
98
+ /** Scale each channel of `a` by `s` into `out` (brightness). Returns `out`. */
99
+ function multiplyScalar(out, a, s) {
100
+ out[0] = a[0] * s;
101
+ out[1] = a[1] * s;
102
+ out[2] = a[2] * s;
103
+ return out;
104
+ }
105
+ /** Linearly interpolate from `a` to `b` by `t` into `out` (physically-correct blend). Returns `out`. */
106
+ function lerp(out, a, b, t) {
107
+ out[0] = a[0] + (b[0] - a[0]) * t;
108
+ out[1] = a[1] + (b[1] - a[1]) * t;
109
+ out[2] = a[2] + (b[2] - a[2]) * t;
110
+ return out;
111
+ }
112
+ /** Clamp each channel of `c` to [0, 1] into `out`. Returns `out`. */
113
+ function clamp(out, c) {
114
+ out[0] = clamp01(c[0]);
115
+ out[1] = clamp01(c[1]);
116
+ out[2] = clamp01(c[2]);
117
+ return out;
118
+ }
119
+ /** Whether `a` and `b` are equal, within an optional per-channel `epsilon` (default exact). */
120
+ function equals(a, b, epsilon = 0) {
121
+ return Math.abs(a[0] - b[0]) <= epsilon && Math.abs(a[1] - b[1]) <= epsilon && Math.abs(a[2] - b[2]) <= epsilon;
122
+ }
123
+ /** Relative luminance in [0, 1] (Rec. 709 weights, on linear light). */
124
+ function luminance(c) {
125
+ return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];
126
+ }
127
+ function clamp01(x) {
128
+ return x < 0 ? 0 : x > 1 ? 1 : x;
129
+ }
130
+ /** linear channel -> clamped sRGB byte [0, 255]. */
131
+ function to255(c) {
132
+ return Math.max(0, Math.min(255, Math.round(linearToSrgb(c) * 255)));
133
+ }
134
+
135
+ export { add, addScalar, clamp, clone, copy, create, equals, fromSRGB, fromValues, lerp, luminance, multiply, multiplyScalar, set, setFromSRGB, setScalar, sub, toCSS, toHex, toHexString, toSRGB };
136
+ //# sourceMappingURL=color.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.js","sources":["../../src/color/color.ts"],"sourcesContent":["import { linearToSrgb, srgbToLinear } from './colorspace';\n\nexport * from './parse';\n\n/** A linear-sRGB color: [r, g, b] floats in [0, 1]. */\nexport type Color = [r: number, g: number, b: number];\n\n/** Accepted input types for creating or parsing a Color. */\nexport type ColorInput =\n | string // '#f00', '#ff0000', 'red', 'rgb(255,0,0)', 'hsl(0,100%,50%)'\n | number // 0xff0000 integer (sRGB gamma)\n | [number, number, number]; // [r, g, b] linear floats [0, 1]\n\n/** Create a new Color initialized to black [0, 0, 0]. */\nexport function create(): Color {\n return [0, 0, 0];\n}\n\n/** Create a new Color with the given linear r, g, b values. */\nexport function fromValues(r: number, g: number, b: number): Color {\n return [r, g, b];\n}\n\n/** Create a new Color that is a copy of `c`. */\nexport function clone(c: Color): Color {\n return [c[0], c[1], c[2]];\n}\n\n/** Copy the values from `src` into `out`. Returns `out`. */\nexport function copy(out: Color, src: Color): Color {\n out[0] = src[0];\n out[1] = src[1];\n out[2] = src[2];\n return out;\n}\n\n/** Set the linear r, g, b components of `out` directly. Returns `out`. */\nexport function set(out: Color, r: number, g: number, b: number): Color {\n out[0] = r;\n out[1] = g;\n out[2] = b;\n return out;\n}\n\n/** Set all three channels of `out` to the same linear value `s` (a gray). Returns `out`. */\nexport function setScalar(out: Color, s: number): Color {\n out[0] = s;\n out[1] = s;\n out[2] = s;\n return out;\n}\n\n/**\n * Set `out` from an sRGB gamma-encoded [r, g, b] array with values in [0, 1].\n * Converts from sRGB gamma space to linear. Returns `out`.\n */\nexport function setFromSRGB(out: Color, srgb: [number, number, number]): Color {\n out[0] = srgbToLinear(srgb[0]);\n out[1] = srgbToLinear(srgb[1]);\n out[2] = srgbToLinear(srgb[2]);\n return out;\n}\n\n/** Create a new Color from an sRGB gamma-encoded [r, g, b] array with values in [0, 1]. */\nexport function fromSRGB(srgb: [number, number, number]): Color {\n return setFromSRGB(create(), srgb);\n}\n\n/** Write the sRGB gamma-encoded [r, g, b] of a linear Color into `out` (values [0, 1]). */\nexport function toSRGB(out: [number, number, number], c: Color): [number, number, number] {\n out[0] = linearToSrgb(c[0]);\n out[1] = linearToSrgb(c[1]);\n out[2] = linearToSrgb(c[2]);\n return out;\n}\n\n/** Create a CSS `rgb(...)` string in sRGB gamma space (for HTML/canvas use). */\nexport function toCSS(c: Color): string {\n return `rgb(${to255(c[0])}, ${to255(c[1])}, ${to255(c[2])})`;\n}\n\n/** Convert to a 0xRRGGBB integer in sRGB gamma space. */\nexport function toHex(c: Color): number {\n return (to255(c[0]) << 16) | (to255(c[1]) << 8) | to255(c[2]);\n}\n\n/** Convert to a 6-digit sRGB hex string without a leading '#', e.g. 'ff8800'. */\nexport function toHexString(c: Color): string {\n return toHex(c).toString(16).padStart(6, '0');\n}\n\n/** Add `a + b` component-wise into `out`. Returns `out`. */\nexport function add(out: Color, a: Color, b: Color): Color {\n out[0] = a[0] + b[0];\n out[1] = a[1] + b[1];\n out[2] = a[2] + b[2];\n return out;\n}\n\n/** Add scalar `s` to each channel of `a` into `out`. Returns `out`. */\nexport function addScalar(out: Color, a: Color, s: number): Color {\n out[0] = a[0] + s;\n out[1] = a[1] + s;\n out[2] = a[2] + s;\n return out;\n}\n\n/** Subtract `a - b` component-wise into `out`. Returns `out`. */\nexport function sub(out: Color, a: Color, b: Color): Color {\n out[0] = a[0] - b[0];\n out[1] = a[1] - b[1];\n out[2] = a[2] - b[2];\n return out;\n}\n\n/** Multiply `a * b` component-wise into `out` (tinting). Returns `out`. */\nexport function multiply(out: Color, a: Color, b: Color): Color {\n out[0] = a[0] * b[0];\n out[1] = a[1] * b[1];\n out[2] = a[2] * b[2];\n return out;\n}\n\n/** Scale each channel of `a` by `s` into `out` (brightness). Returns `out`. */\nexport function multiplyScalar(out: Color, a: Color, s: number): Color {\n out[0] = a[0] * s;\n out[1] = a[1] * s;\n out[2] = a[2] * s;\n return out;\n}\n\n/** Linearly interpolate from `a` to `b` by `t` into `out` (physically-correct blend). Returns `out`. */\nexport function lerp(out: Color, a: Color, b: Color, t: number): Color {\n out[0] = a[0] + (b[0] - a[0]) * t;\n out[1] = a[1] + (b[1] - a[1]) * t;\n out[2] = a[2] + (b[2] - a[2]) * t;\n return out;\n}\n\n/** Clamp each channel of `c` to [0, 1] into `out`. Returns `out`. */\nexport function clamp(out: Color, c: Color): Color {\n out[0] = clamp01(c[0]);\n out[1] = clamp01(c[1]);\n out[2] = clamp01(c[2]);\n return out;\n}\n\n/** Whether `a` and `b` are equal, within an optional per-channel `epsilon` (default exact). */\nexport function equals(a: Color, b: Color, epsilon = 0): boolean {\n return Math.abs(a[0] - b[0]) <= epsilon && Math.abs(a[1] - b[1]) <= epsilon && Math.abs(a[2] - b[2]) <= epsilon;\n}\n\n/** Relative luminance in [0, 1] (Rec. 709 weights, on linear light). */\nexport function luminance(c: Color): number {\n return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];\n}\n\nfunction clamp01(x: number): number {\n return x < 0 ? 0 : x > 1 ? 1 : x;\n}\n\n/** linear channel -> clamped sRGB byte [0, 255]. */\nfunction to255(c: number): number {\n return Math.max(0, Math.min(255, Math.round(linearToSrgb(c) * 255)));\n}\n"],"names":[],"mappings":";;;AAaA;SACgB,MAAM,GAAA;AAClB,IAAA,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpB;AAEA;SACgB,UAAU,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAA;AACtD,IAAA,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpB;AAEA;AACM,SAAU,KAAK,CAAC,CAAQ,EAAA;AAC1B,IAAA,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B;AAEA;AACM,SAAU,IAAI,CAAC,GAAU,EAAE,GAAU,EAAA;IACvC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACf,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACf,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AACf,IAAA,OAAO,GAAG;AACd;AAEA;AACM,SAAU,GAAG,CAAC,GAAU,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAA;AAC3D,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACV,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACV,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACV,IAAA,OAAO,GAAG;AACd;AAEA;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C,GAAG,CAAC,GAAG,CAAC;AACpC;AAEA;AACA,SAAS,KAAK,CAAC,CAAS,EAAA;IACpB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AACxE;;;;"}
@@ -0,0 +1,43 @@
1
+ // Color-space conversions (pure functions — no global working-space state).
2
+ //
3
+ // math's Color is stored in linear sRGB. Two kinds of conversion live here:
4
+ // - transfer functions: encode/decode a channel's gamma (sRGB <-> linear)
5
+ // - gamut conversions: move between primaries (linear sRGB <-> linear Display-P3)
6
+ // Display-P3 uses the same sRGB transfer curve, so only the primaries differ.
7
+ /** Convert a single sRGB gamma-encoded channel [0, 1] to linear light [0, 1]. */
8
+ function srgbToLinear(c) {
9
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
10
+ }
11
+ /** Convert a single linear light channel [0, 1] to sRGB gamma-encoded [0, 1]. */
12
+ function linearToSrgb(c) {
13
+ return c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;
14
+ }
15
+ /**
16
+ * Convert a linear-sRGB Color to linear Display-P3 primaries, into `out`. Returns `out`.
17
+ * (Both spaces share the sRGB transfer curve; this changes only the primaries.)
18
+ */
19
+ function linearSrgbToLinearDisplayP3(out, c) {
20
+ const r = c[0];
21
+ const g = c[1];
22
+ const b = c[2];
23
+ out[0] = 0.8224621 * r + 0.177538 * g;
24
+ out[1] = 0.0331941 * r + 0.9668058 * g;
25
+ out[2] = 0.0170827 * r + 0.0723974 * g + 0.9105199 * b;
26
+ return out;
27
+ }
28
+ /**
29
+ * Convert a linear Display-P3 Color to linear-sRGB primaries, into `out`. Returns `out`.
30
+ * Colors outside the sRGB gamut yield channels outside [0, 1] — clamp if needed.
31
+ */
32
+ function linearDisplayP3ToLinearSrgb(out, c) {
33
+ const r = c[0];
34
+ const g = c[1];
35
+ const b = c[2];
36
+ out[0] = 1.2249401 * r - 0.2249404 * g;
37
+ out[1] = -0.0420569 * r + 1.0420571 * g;
38
+ out[2] = -0.0196376 * r - 0.0786361 * g + 1.0982735 * b;
39
+ return out;
40
+ }
41
+
42
+ export { linearDisplayP3ToLinearSrgb, linearSrgbToLinearDisplayP3, linearToSrgb, srgbToLinear };
43
+ //# sourceMappingURL=colorspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorspace.js","sources":["../../src/color/colorspace.ts"],"sourcesContent":["import type { Color } from './color';\n\n// Color-space conversions (pure functions — no global working-space state).\n//\n// math's Color is stored in linear sRGB. Two kinds of conversion live here:\n// - transfer functions: encode/decode a channel's gamma (sRGB <-> linear)\n// - gamut conversions: move between primaries (linear sRGB <-> linear Display-P3)\n// Display-P3 uses the same sRGB transfer curve, so only the primaries differ.\n\n/** Convert a single sRGB gamma-encoded channel [0, 1] to linear light [0, 1]. */\nexport function srgbToLinear(c: number): number {\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n}\n\n/** Convert a single linear light channel [0, 1] to sRGB gamma-encoded [0, 1]. */\nexport function linearToSrgb(c: number): number {\n return c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055;\n}\n\n/**\n * Convert a linear-sRGB Color to linear Display-P3 primaries, into `out`. Returns `out`.\n * (Both spaces share the sRGB transfer curve; this changes only the primaries.)\n */\nexport function linearSrgbToLinearDisplayP3(out: Color, c: Color): Color {\n const r = c[0];\n const g = c[1];\n const b = c[2];\n out[0] = 0.8224621 * r + 0.177538 * g;\n out[1] = 0.0331941 * r + 0.9668058 * g;\n out[2] = 0.0170827 * r + 0.0723974 * g + 0.9105199 * b;\n return out;\n}\n\n/**\n * Convert a linear Display-P3 Color to linear-sRGB primaries, into `out`. Returns `out`.\n * Colors outside the sRGB gamut yield channels outside [0, 1] — clamp if needed.\n */\nexport function linearDisplayP3ToLinearSrgb(out: Color, c: Color): Color {\n const r = c[0];\n const g = c[1];\n const b = c[2];\n out[0] = 1.2249401 * r - 0.2249404 * g;\n out[1] = -0.0420569 * r + 1.0420571 * g;\n out[2] = -0.0196376 * r - 0.0786361 * g + 1.0982735 * b;\n return out;\n}\n"],"names":[],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACM,SAAU,YAAY,CAAC,CAAS,EAAA;IAClC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,KAAK,KAAK,GAAG;AAClE;AAEA;AACM,SAAU,YAAY,CAAC,CAAS,EAAA;IAClC,OAAO,CAAC,IAAI,SAAS,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK;AACtE;AAEA;;;AAGG;AACG,SAAU,2BAA2B,CAAC,GAAU,EAAE,CAAQ,EAAA;AAC5D,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACd,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACd,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACd,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,QAAQ,GAAG,CAAC;IACrC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;AACtC,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;AACtD,IAAA,OAAO,GAAG;AACd;AAEA;;;AAGG;AACG,SAAU,2BAA2B,CAAC,GAAU,EAAE,CAAQ,EAAA;AAC5D,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACd,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACd,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACd,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;AACtC,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;AACvC,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,GAAG,CAAC;AACvD,IAAA,OAAO,GAAG;AACd;;;;"}
@@ -0,0 +1,123 @@
1
+ import { linearToSrgb, srgbToLinear } from './colorspace.js';
2
+
3
+ /** Create a new HSL initialized to [0, 0, 0] (black). */
4
+ function create() {
5
+ return [0, 0, 0];
6
+ }
7
+ /** Create a new HSL with the given h, s, l values (all in [0, 1]). */
8
+ function fromValues(h, s, l) {
9
+ return [h, s, l];
10
+ }
11
+ /** Create a new HSL that is a copy of `a`. */
12
+ function clone(a) {
13
+ return [a[0], a[1], a[2]];
14
+ }
15
+ /** Copy the values from `src` into `out`. Returns `out`. */
16
+ function copy(out, src) {
17
+ out[0] = src[0];
18
+ out[1] = src[1];
19
+ out[2] = src[2];
20
+ return out;
21
+ }
22
+ /** Set the h, s, l components of `out` directly. Returns `out`. */
23
+ function set(out, h, s, l) {
24
+ out[0] = h;
25
+ out[1] = s;
26
+ out[2] = l;
27
+ return out;
28
+ }
29
+ /** Write the HSL of a linear Color into `out`. Returns `out`. */
30
+ function fromColor(out, c) {
31
+ // linear -> sRGB gamma; HSL is defined on gamma-encoded sRGB
32
+ const r = linearToSrgb(c[0]);
33
+ const g = linearToSrgb(c[1]);
34
+ const b = linearToSrgb(c[2]);
35
+ const max = Math.max(r, g, b);
36
+ const min = Math.min(r, g, b);
37
+ const l = (max + min) / 2;
38
+ let h = 0;
39
+ let s = 0;
40
+ if (max !== min) {
41
+ const d = max - min;
42
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
43
+ if (max === r)
44
+ h = (g - b) / d + (g < b ? 6 : 0);
45
+ else if (max === g)
46
+ h = (b - r) / d + 2;
47
+ else
48
+ h = (r - g) / d + 4;
49
+ h /= 6;
50
+ }
51
+ out[0] = h;
52
+ out[1] = s;
53
+ out[2] = l;
54
+ return out;
55
+ }
56
+ /** Write the linear Color of an HSL into `out`. Returns `out`. */
57
+ function toColor(out, a) {
58
+ const h = a[0];
59
+ const s = a[1];
60
+ const l = a[2];
61
+ if (s === 0) {
62
+ const v = srgbToLinear(l);
63
+ out[0] = v;
64
+ out[1] = v;
65
+ out[2] = v;
66
+ return out;
67
+ }
68
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
69
+ const p = 2 * l - q;
70
+ out[0] = srgbToLinear(hue(p, q, h + 1 / 3));
71
+ out[1] = srgbToLinear(hue(p, q, h));
72
+ out[2] = srgbToLinear(hue(p, q, h - 1 / 3));
73
+ return out;
74
+ }
75
+ /**
76
+ * Interpolate from `a` to `b` by `t` into `out`, taking the shortest path around
77
+ * the hue wheel (so e.g. 350°→10° passes through 0°, not all the way back).
78
+ * Returns `out`.
79
+ */
80
+ function lerp(out, a, b, t) {
81
+ let dh = b[0] - a[0];
82
+ if (dh > 0.5)
83
+ dh -= 1;
84
+ else if (dh < -0.5)
85
+ dh += 1;
86
+ let h = a[0] + dh * t;
87
+ h -= Math.floor(h); // wrap into [0, 1)
88
+ out[0] = h;
89
+ out[1] = a[1] + (b[1] - a[1]) * t;
90
+ out[2] = a[2] + (b[2] - a[2]) * t;
91
+ return out;
92
+ }
93
+ /**
94
+ * Offset `a` by (dh, ds, dl) into `out`: hue wraps into [0, 1), saturation and
95
+ * lightness are clamped to [0, 1]. Returns `out`.
96
+ */
97
+ function offset(out, a, dh, ds, dl) {
98
+ let h = a[0] + dh;
99
+ h -= Math.floor(h);
100
+ out[0] = h;
101
+ out[1] = clamp01(a[1] + ds);
102
+ out[2] = clamp01(a[2] + dl);
103
+ return out;
104
+ }
105
+ function clamp01(x) {
106
+ return x < 0 ? 0 : x > 1 ? 1 : x;
107
+ }
108
+ function hue(p, q, t) {
109
+ if (t < 0)
110
+ t += 1;
111
+ if (t > 1)
112
+ t -= 1;
113
+ if (t < 1 / 6)
114
+ return p + (q - p) * 6 * t;
115
+ if (t < 1 / 2)
116
+ return q;
117
+ if (t < 2 / 3)
118
+ return p + (q - p) * (2 / 3 - t) * 6;
119
+ return p;
120
+ }
121
+
122
+ export { clone, copy, create, fromColor, fromValues, lerp, offset, set, toColor };
123
+ //# sourceMappingURL=hsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hsl.js","sources":["../../src/color/hsl.ts"],"sourcesContent":["import type { Color } from './color';\nimport { linearToSrgb, srgbToLinear } from './colorspace';\n\n/** A hue-saturation-lightness color: [h, s, l], all in [0, 1] (hue wraps). */\nexport type HSL = [hue: number, saturation: number, lightness: number];\n\n/** Create a new HSL initialized to [0, 0, 0] (black). */\nexport function create(): HSL {\n return [0, 0, 0];\n}\n\n/** Create a new HSL with the given h, s, l values (all in [0, 1]). */\nexport function fromValues(h: number, s: number, l: number): HSL {\n return [h, s, l];\n}\n\n/** Create a new HSL that is a copy of `a`. */\nexport function clone(a: HSL): HSL {\n return [a[0], a[1], a[2]];\n}\n\n/** Copy the values from `src` into `out`. Returns `out`. */\nexport function copy(out: HSL, src: HSL): HSL {\n out[0] = src[0];\n out[1] = src[1];\n out[2] = src[2];\n return out;\n}\n\n/** Set the h, s, l components of `out` directly. Returns `out`. */\nexport function set(out: HSL, h: number, s: number, l: number): HSL {\n out[0] = h;\n out[1] = s;\n out[2] = l;\n return out;\n}\n\n/** Write the HSL of a linear Color into `out`. Returns `out`. */\nexport function fromColor(out: HSL, c: Color): HSL {\n // linear -> sRGB gamma; HSL is defined on gamma-encoded sRGB\n const r = linearToSrgb(c[0]);\n const g = linearToSrgb(c[1]);\n const b = linearToSrgb(c[2]);\n\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n\n let h = 0;\n let s = 0;\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n if (max === r) h = (g - b) / d + (g < b ? 6 : 0);\n else if (max === g) h = (b - r) / d + 2;\n else h = (r - g) / d + 4;\n h /= 6;\n }\n\n out[0] = h;\n out[1] = s;\n out[2] = l;\n return out;\n}\n\n/** Write the linear Color of an HSL into `out`. Returns `out`. */\nexport function toColor(out: Color, a: HSL): Color {\n const h = a[0];\n const s = a[1];\n const l = a[2];\n\n if (s === 0) {\n const v = srgbToLinear(l);\n out[0] = v;\n out[1] = v;\n out[2] = v;\n return out;\n }\n\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n out[0] = srgbToLinear(hue(p, q, h + 1 / 3));\n out[1] = srgbToLinear(hue(p, q, h));\n out[2] = srgbToLinear(hue(p, q, h - 1 / 3));\n return out;\n}\n\n/**\n * Interpolate from `a` to `b` by `t` into `out`, taking the shortest path around\n * the hue wheel (so e.g. 350°→10° passes through 0°, not all the way back).\n * Returns `out`.\n */\nexport function lerp(out: HSL, a: HSL, b: HSL, t: number): HSL {\n let dh = b[0] - a[0];\n if (dh > 0.5) dh -= 1;\n else if (dh < -0.5) dh += 1;\n\n let h = a[0] + dh * t;\n h -= Math.floor(h); // wrap into [0, 1)\n\n out[0] = h;\n out[1] = a[1] + (b[1] - a[1]) * t;\n out[2] = a[2] + (b[2] - a[2]) * t;\n return out;\n}\n\n/**\n * Offset `a` by (dh, ds, dl) into `out`: hue wraps into [0, 1), saturation and\n * lightness are clamped to [0, 1]. Returns `out`.\n */\nexport function offset(out: HSL, a: HSL, dh: number, ds: number, dl: number): HSL {\n let h = a[0] + dh;\n h -= Math.floor(h);\n out[0] = h;\n out[1] = clamp01(a[1] + ds);\n out[2] = clamp01(a[2] + dl);\n return out;\n}\n\nfunction clamp01(x: number): number {\n return x < 0 ? 0 : x > 1 ? 1 : x;\n}\n\nfunction hue(p: number, q: number, t: number): number {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n}\n"],"names":[],"mappings":";;AAMA;SACgB,MAAM,GAAA;AAClB,IAAA,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpB;AAEA;SACgB,UAAU,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAA;AACtD,IAAA,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACpB;AAEA;AACM,SAAU,KAAK,CAAC,CAAM,EAAA;AACxB,IAAA,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7B;AAEA;AACM,SAAU,IAAI,CAAC,GAAQ,EAAE,GAAQ,EAAA;IACnC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACf,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IACf,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;AACf,IAAA,OAAO,GAAG;AACd;AAEA;AACM,SAAU,GAAG,CAAC,GAAQ,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAA;AACzD,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACV,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACV,IAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACV,IAAA,OAAO,GAAG;AACd;AAEA;AACM,SAAU,SAAS,CAAC,GAAQ,EAAE,CAAQ,EAAA;;IAExC,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC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C,GAAG,CAAC;QAAE,CAAC,IAAI,CAAC;AACjB,IAAA,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AACzC,IAAA,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,OAAO,CAAC;AACvB,IAAA,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAAE,QAAA,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;AACnD,IAAA,OAAO,CAAC;AACZ;;;;"}
@@ -0,0 +1,7 @@
1
+ import * as color from './color.js';
2
+ export { color };
3
+ import * as colorspace from './colorspace.js';
4
+ export { colorspace };
5
+ import * as hsl from './hsl.js';
6
+ export { hsl };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}