@cssints/gradient-2d 0.5.2 → 0.6.1
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/dist/index.d.mts +1 -2
- package/dist/index.mjs +2 -4
- package/dist/runtime.mjs +4 -8
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/index.d.ts
|
|
2
1
|
declare const mesh: import("cssints/plugin").Scope<"gradient2d", {
|
|
3
2
|
readonly "#core": {
|
|
4
3
|
readonly css: "&{background-image:var(--_fallback);background-repeat:no-repeat;background-size:100% 100%}@supports (background-image:mesh-gradient(red,blue;green,yellow)){&{background-image:var(--_native)}}";
|
|
@@ -38,4 +37,4 @@ export declare const meshGradient: Members["meshGradient"];
|
|
|
38
37
|
* points, a colour it cannot read, a length, a line and a shape.
|
|
39
38
|
*/
|
|
40
39
|
export declare const freeformGradient: Members["freeformGradient"];
|
|
41
|
-
|
|
40
|
+
export {};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { arg, scope } from "cssints/plugin";
|
|
2
2
|
import { formatHex, formatHex8, parse, rgb } from "culori";
|
|
3
|
-
|
|
3
|
+
// src/grid.ts
|
|
4
4
|
const lin = (c) => c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
|
|
5
5
|
const gam = (c) => c <= .0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - .055;
|
|
6
6
|
const toOklab = ([r, g, b, a]) => {
|
|
@@ -35,8 +35,7 @@ const mean = (qs) => [
|
|
|
35
35
|
2,
|
|
36
36
|
3
|
|
37
37
|
].map((k) => qs.reduce((s, q) => s + q[k], 0) / qs.length);
|
|
38
|
-
|
|
39
|
-
//#region src/index.ts
|
|
38
|
+
// src/index.ts
|
|
40
39
|
const cut = (text, sep) => {
|
|
41
40
|
const { out, cur } = [...text].reduce((acc, ch) => {
|
|
42
41
|
const depth = acc.depth + Number(ch === "(") - Number(ch === ")");
|
|
@@ -251,5 +250,4 @@ const meshGradient = members.meshGradient;
|
|
|
251
250
|
* points, a colour it cannot read, a length, a line and a shape.
|
|
252
251
|
*/
|
|
253
252
|
const freeformGradient = members.freeformGradient;
|
|
254
|
-
//#endregion
|
|
255
253
|
export { freeformGradient, meshGradient };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/canvas.ts
|
|
2
2
|
const drawn = /* @__PURE__ */ new WeakMap();
|
|
3
3
|
const resolve = (el, text, ctx) => {
|
|
4
4
|
const probe = document.createElement("span");
|
|
@@ -61,8 +61,7 @@ const run = (drawings) => {
|
|
|
61
61
|
});
|
|
62
62
|
scan(document.documentElement);
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
//#region src/grid.ts
|
|
64
|
+
// src/grid.ts
|
|
66
65
|
const lin = (c) => c <= .04045 ? c / 12.92 : ((c + .055) / 1.055) ** 2.4;
|
|
67
66
|
const gam = (c) => c <= .0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - .055;
|
|
68
67
|
const toOklab = ([r, g, b, a]) => {
|
|
@@ -130,8 +129,7 @@ const sample = (g, u, v) => {
|
|
|
130
129
|
3
|
|
131
130
|
].map((k) => cr(q[0][k], q[1][k], q[2][k], q[3][k], ty));
|
|
132
131
|
};
|
|
133
|
-
|
|
134
|
-
//#region src/points.ts
|
|
132
|
+
// src/points.ts
|
|
135
133
|
const freeform = (points, u, v, ratio = 1) => {
|
|
136
134
|
const ws = points.map((p) => {
|
|
137
135
|
const du = u - p.u;
|
|
@@ -153,8 +151,7 @@ const freeform = (points, u, v, ratio = 1) => {
|
|
|
153
151
|
3
|
|
154
152
|
].map((k) => ws.reduce((s, x, i) => s + w[i] * x.p.q[k], 0) / sum);
|
|
155
153
|
};
|
|
156
|
-
|
|
157
|
-
//#region src/runtime.ts
|
|
154
|
+
// src/runtime.ts
|
|
158
155
|
const mesh = {
|
|
159
156
|
marker: "_gradient2d-core",
|
|
160
157
|
fallback: "--gradient2d-fallback",
|
|
@@ -204,4 +201,3 @@ const points = {
|
|
|
204
201
|
}
|
|
205
202
|
};
|
|
206
203
|
if (typeof document !== "undefined" && typeof ResizeObserver !== "undefined") run([mesh, points]);
|
|
207
|
-
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cssints/gradient-2d",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "mesh-gradient() and freeform-gradient() for cssints: the native function where the browser has it, else a canvas drawn by a runtime",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"culori": "^4.0.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"cssints": "^0.
|
|
34
|
+
"cssints": "^0.6.0"
|
|
35
35
|
},
|
|
36
36
|
"engines": {
|
|
37
37
|
"node": ">=22"
|