@sarmal/core 0.20.0 → 0.22.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/dist/auto-init.cjs +26 -2
- package/dist/auto-init.cjs.map +1 -1
- package/dist/auto-init.d.cts +1 -1
- package/dist/auto-init.d.ts +1 -1
- package/dist/auto-init.js +26 -2
- package/dist/auto-init.js.map +1 -1
- package/dist/curves/artemis2.d.cts +1 -1
- package/dist/curves/artemis2.d.ts +1 -1
- package/dist/curves/astroid.d.cts +1 -1
- package/dist/curves/astroid.d.ts +1 -1
- package/dist/curves/deltoid.d.cts +1 -1
- package/dist/curves/deltoid.d.ts +1 -1
- package/dist/curves/epicycloid3.d.cts +1 -1
- package/dist/curves/epicycloid3.d.ts +1 -1
- package/dist/curves/epitrochoid7.d.cts +1 -1
- package/dist/curves/epitrochoid7.d.ts +1 -1
- package/dist/curves/index.d.cts +1 -1
- package/dist/curves/index.d.ts +1 -1
- package/dist/curves/lame.d.cts +1 -1
- package/dist/curves/lame.d.ts +1 -1
- package/dist/curves/lissajous32.d.cts +1 -1
- package/dist/curves/lissajous32.d.ts +1 -1
- package/dist/curves/lissajous43.d.cts +1 -1
- package/dist/curves/lissajous43.d.ts +1 -1
- package/dist/curves/rose3.d.cts +1 -1
- package/dist/curves/rose3.d.ts +1 -1
- package/dist/curves/rose5.d.cts +1 -1
- package/dist/curves/rose5.d.ts +1 -1
- package/dist/curves/rose52.d.cts +1 -1
- package/dist/curves/rose52.d.ts +1 -1
- package/dist/curves/star.d.cts +1 -1
- package/dist/curves/star.d.ts +1 -1
- package/dist/curves/star4.d.cts +1 -1
- package/dist/curves/star4.d.ts +1 -1
- package/dist/curves/star7.d.cts +1 -1
- package/dist/curves/star7.d.ts +1 -1
- package/dist/index.cjs +26 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-frtEoAq6.d.cts → types-DVerJ9cl.d.cts} +4 -0
- package/dist/{types-frtEoAq6.d.ts → types-DVerJ9cl.d.ts} +4 -0
- package/package.json +1 -1
package/dist/auto-init.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scans for `<canvas data-sarmal="curveName">` and `<svg data-sarmal="curveName">`
|
|
3
|
-
*
|
|
3
|
+
* when **DOMContentLoaded** is triggered, and creates a Sarmal instance for each one.
|
|
4
4
|
*/
|
|
5
5
|
declare function init(): void;
|
|
6
6
|
|
package/dist/auto-init.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Scans for `<canvas data-sarmal="curveName">` and `<svg data-sarmal="curveName">`
|
|
3
|
-
*
|
|
3
|
+
* when **DOMContentLoaded** is triggered, and creates a Sarmal instance for each one.
|
|
4
4
|
*/
|
|
5
5
|
declare function init(): void;
|
|
6
6
|
|
package/dist/auto-init.js
CHANGED
|
@@ -418,6 +418,7 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
|
418
418
|
"headColor",
|
|
419
419
|
"skeletonColor",
|
|
420
420
|
"trailStyle",
|
|
421
|
+
"headRadius",
|
|
421
422
|
]);
|
|
422
423
|
function validateRenderOptions(partial) {
|
|
423
424
|
for (const key of Object.keys(partial)) {
|
|
@@ -437,6 +438,9 @@ function validateRenderOptions(partial) {
|
|
|
437
438
|
if (partial.trailStyle !== void 0) {
|
|
438
439
|
assertTrailStyle(partial.trailStyle);
|
|
439
440
|
}
|
|
441
|
+
if (partial.headRadius !== void 0) {
|
|
442
|
+
assertHeadRadius(partial.headRadius);
|
|
443
|
+
}
|
|
440
444
|
}
|
|
441
445
|
function assertTrailColor(value) {
|
|
442
446
|
if (typeof value === "string") {
|
|
@@ -494,6 +498,18 @@ function assertTrailStyle(value) {
|
|
|
494
498
|
);
|
|
495
499
|
}
|
|
496
500
|
}
|
|
501
|
+
function assertHeadRadius(value) {
|
|
502
|
+
if (typeof value !== "number") {
|
|
503
|
+
throw new TypeError(
|
|
504
|
+
`[sarmal] setRenderOptions: headRadius must be a number, got ${JSON.stringify(value)}`,
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
if (!Number.isFinite(value) || value <= 0) {
|
|
508
|
+
throw new TypeError(
|
|
509
|
+
`[sarmal] setRenderOptions: headRadius must be a finite positive number, got ${value}`,
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
497
513
|
function resolveTrailMainColor(trailColor) {
|
|
498
514
|
return typeof trailColor === "string" ? trailColor : trailColor[0];
|
|
499
515
|
}
|
|
@@ -561,6 +577,7 @@ function createRenderer(options) {
|
|
|
561
577
|
setupCanvas();
|
|
562
578
|
let logicalWidth = canvas.width / dpr;
|
|
563
579
|
let logicalHeight = canvas.height / dpr;
|
|
580
|
+
let headRadius = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
|
|
564
581
|
let skeleton = [];
|
|
565
582
|
let skeletonCanvas = null;
|
|
566
583
|
let trail = [];
|
|
@@ -677,7 +694,7 @@ function createRenderer(options) {
|
|
|
677
694
|
}
|
|
678
695
|
const x = head.x * scale + offsetX;
|
|
679
696
|
const y = head.y * scale + offsetY;
|
|
680
|
-
const r =
|
|
697
|
+
const r = headRadius;
|
|
681
698
|
ctx.fillStyle = headColor;
|
|
682
699
|
ctx.beginPath();
|
|
683
700
|
ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
@@ -806,6 +823,9 @@ function createRenderer(options) {
|
|
|
806
823
|
if (partial.headColor !== void 0) {
|
|
807
824
|
userHeadColor = partial.headColor;
|
|
808
825
|
}
|
|
826
|
+
if (partial.headRadius !== void 0) {
|
|
827
|
+
headRadius = partial.headRadius;
|
|
828
|
+
}
|
|
809
829
|
if (userHeadColor === null) {
|
|
810
830
|
headColor = resolveHeadColor(trailColor, trailStyle);
|
|
811
831
|
} else {
|
|
@@ -863,12 +883,12 @@ function createSVGRenderer(options) {
|
|
|
863
883
|
let skeletonColor = options.skeletonColor ?? "#ffffff";
|
|
864
884
|
let userHeadColor = options.headColor ?? null;
|
|
865
885
|
let headColor = userHeadColor ?? resolveHeadColor(trailColor, trailStyle);
|
|
886
|
+
let headRadius = options.headRadius ?? 1.5;
|
|
866
887
|
let trailSolid = resolveTrailMainColor(trailColor);
|
|
867
888
|
let trailPalette = resolveTrailPalette(trailColor);
|
|
868
889
|
const ariaLabel = options.ariaLabel ?? "Loading";
|
|
869
890
|
warnIfTrailColorMismatch(trailColor, trailStyle);
|
|
870
891
|
const viewSize = 100;
|
|
871
|
-
const headRadius = options.headRadius ?? 1.5;
|
|
872
892
|
const svgTrailMinWidth = 0.25;
|
|
873
893
|
const svgTrailMaxWidth = 1.25;
|
|
874
894
|
const svgSkeletonStrokeWidth = "0.75";
|
|
@@ -1144,6 +1164,10 @@ function createSVGRenderer(options) {
|
|
|
1144
1164
|
if (partial.headColor !== void 0) {
|
|
1145
1165
|
userHeadColor = partial.headColor;
|
|
1146
1166
|
}
|
|
1167
|
+
if (partial.headRadius !== void 0) {
|
|
1168
|
+
headRadius = partial.headRadius;
|
|
1169
|
+
headCircle.setAttribute("r", String(headRadius));
|
|
1170
|
+
}
|
|
1147
1171
|
if (userHeadColor === null) {
|
|
1148
1172
|
headColor = resolveHeadColor(trailColor, trailStyle);
|
|
1149
1173
|
} else {
|