@thi.ng/blurhash 0.1.0 → 0.1.2
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/CHANGELOG.md +1 -1
- package/README.md +7 -3
- package/internal/ensure.d.ts +3 -0
- package/internal/ensure.js +14 -0
- package/internal/linear.d.ts +13 -0
- package/internal/linear.js +8 -0
- package/package.json +9 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -7,9 +7,13 @@
|
|
|
7
7
|

|
|
8
8
|
[](https://mastodon.thi.ng/@toxi)
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
> [!NOTE]
|
|
11
|
+
> This is one of 189 standalone projects, maintained as part
|
|
12
|
+
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
13
|
+
> and anti-framework.
|
|
14
|
+
>
|
|
15
|
+
> 🚀 Help me to work full-time on these projects by [sponsoring me on
|
|
16
|
+
> GitHub](https://github.com/sponsors/postspectacular). Thank you! ❤️
|
|
13
17
|
|
|
14
18
|
- [About](#about)
|
|
15
19
|
- [Status](#status)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { assert } from "@thi.ng/errors/assert";
|
|
2
|
+
import { inRange } from "@thi.ng/math/interval";
|
|
3
|
+
const __ensureDetail = (detailX, detailY) => assert(
|
|
4
|
+
inRange(detailX, 1, 9) && inRange(detailY, 1, 9),
|
|
5
|
+
"detail must be in [1,9] range"
|
|
6
|
+
);
|
|
7
|
+
const __ensureSize = (pixels, width, height) => assert(
|
|
8
|
+
width * height === pixels.length,
|
|
9
|
+
"width & height must match number of pixels"
|
|
10
|
+
);
|
|
11
|
+
export {
|
|
12
|
+
__ensureDetail,
|
|
13
|
+
__ensureSize
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Using simplified approximation only - precision not needed for this use case.
|
|
3
|
+
*
|
|
4
|
+
* @internal
|
|
5
|
+
*/
|
|
6
|
+
export declare const __toLinear: (x: number, shift?: number) => number;
|
|
7
|
+
/**
|
|
8
|
+
* Using simplified approximation only - precision not needed for this use case.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare const __fromLinear: (x: number, shift?: number) => number;
|
|
13
|
+
//# sourceMappingURL=linear.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { clamp01 } from "@thi.ng/math/interval";
|
|
2
|
+
const G = 1 / 2.2;
|
|
3
|
+
const __toLinear = (x, shift = 0) => ((x >> shift & 255) / 255) ** 2.2;
|
|
4
|
+
const __fromLinear = (x, shift = 0) => clamp01(x) ** G * 255 + 0.5 << shift;
|
|
5
|
+
export {
|
|
6
|
+
__fromLinear,
|
|
7
|
+
__toLinear
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/blurhash",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Fast, optimized TS implementation of the Wolt Blurhash algorithm",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/base-n": "^2.6.
|
|
40
|
-
"@thi.ng/canvas": "^0.2.
|
|
41
|
-
"@thi.ng/errors": "^2.4.
|
|
42
|
-
"@thi.ng/math": "^5.8.
|
|
38
|
+
"@thi.ng/api": "^8.9.20",
|
|
39
|
+
"@thi.ng/base-n": "^2.6.2",
|
|
40
|
+
"@thi.ng/canvas": "^0.2.2",
|
|
41
|
+
"@thi.ng/errors": "^2.4.13",
|
|
42
|
+
"@thi.ng/math": "^5.8.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@microsoft/api-extractor": "^7.39.0",
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
"./*.js",
|
|
76
|
-
"./*.d.ts"
|
|
76
|
+
"./*.d.ts",
|
|
77
|
+
"internal"
|
|
77
78
|
],
|
|
78
79
|
"exports": {
|
|
79
80
|
".": {
|
|
@@ -90,5 +91,5 @@
|
|
|
90
91
|
"status": "alpha",
|
|
91
92
|
"year": 2023
|
|
92
93
|
},
|
|
93
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "3fa30b2dc2de762f24fd64b881b68d4da33d4c38\n"
|
|
94
95
|
}
|