@sarmal/core 0.31.0 → 0.34.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 (51) hide show
  1. package/README.md +2 -2
  2. package/dist/auto-init.cjs +42 -4
  3. package/dist/auto-init.cjs.map +1 -1
  4. package/dist/auto-init.js +42 -4
  5. package/dist/auto-init.js.map +1 -1
  6. package/dist/cli.js.map +1 -1
  7. package/dist/curves/artemis2.d.cts +1 -1
  8. package/dist/curves/artemis2.d.ts +1 -1
  9. package/dist/curves/astroid.d.cts +1 -1
  10. package/dist/curves/astroid.d.ts +1 -1
  11. package/dist/curves/deltoid.d.cts +1 -1
  12. package/dist/curves/deltoid.d.ts +1 -1
  13. package/dist/curves/epicycloid3.d.cts +1 -1
  14. package/dist/curves/epicycloid3.d.ts +1 -1
  15. package/dist/curves/epitrochoid7.d.cts +1 -1
  16. package/dist/curves/epitrochoid7.d.ts +1 -1
  17. package/dist/curves/index.d.cts +1 -1
  18. package/dist/curves/index.d.ts +1 -1
  19. package/dist/curves/lame.d.cts +1 -1
  20. package/dist/curves/lame.d.ts +1 -1
  21. package/dist/curves/lissajous32.d.cts +1 -1
  22. package/dist/curves/lissajous32.d.ts +1 -1
  23. package/dist/curves/lissajous43.d.cts +1 -1
  24. package/dist/curves/lissajous43.d.ts +1 -1
  25. package/dist/curves/rose3.d.cts +1 -1
  26. package/dist/curves/rose3.d.ts +1 -1
  27. package/dist/curves/rose5.d.cts +1 -1
  28. package/dist/curves/rose5.d.ts +1 -1
  29. package/dist/curves/rose52.d.cts +1 -1
  30. package/dist/curves/rose52.d.ts +1 -1
  31. package/dist/curves/star.d.cts +1 -1
  32. package/dist/curves/star.d.ts +1 -1
  33. package/dist/curves/star4.d.cts +1 -1
  34. package/dist/curves/star4.d.ts +1 -1
  35. package/dist/curves/star7.d.cts +1 -1
  36. package/dist/curves/star7.d.ts +1 -1
  37. package/dist/index.cjs +375 -7
  38. package/dist/index.cjs.map +1 -1
  39. package/dist/index.d.cts +80 -4
  40. package/dist/index.d.ts +80 -4
  41. package/dist/index.js +375 -8
  42. package/dist/index.js.map +1 -1
  43. package/dist/{renderer-shared-jqw_Q1WO.d.cts → renderer-shared-C3KCEABq.d.cts} +8 -4
  44. package/dist/{renderer-shared-OR--cv-t.d.ts → renderer-shared-DyOI68gd.d.ts} +8 -4
  45. package/dist/terminal.cjs.map +1 -1
  46. package/dist/terminal.d.cts +2 -2
  47. package/dist/terminal.d.ts +2 -2
  48. package/dist/terminal.js.map +1 -1
  49. package/dist/{types-zbxUgcmZ.d.cts → types-_f27GDkU.d.cts} +30 -9
  50. package/dist/{types-zbxUgcmZ.d.ts → types-_f27GDkU.d.ts} +30 -9
  51. package/package.json +4 -4
package/README.md CHANGED
@@ -46,8 +46,8 @@ import { createSarmal, rose3 } from "@sarmal/core";
46
46
  const canvas = document.getElementById("my-canvas");
47
47
  const sarmal = createSarmal(canvas, rose3, {
48
48
  trailLength: 30,
49
- strokeStyle: "#00ffaa",
50
- lineWidth: 2,
49
+ trailColor: "#00ffaa",
50
+ trailWidth: 2,
51
51
  });
52
52
 
53
53
  sarmal.start();
@@ -513,7 +513,8 @@ var RENDER_OPTION_KEYS = /* @__PURE__ */ new Set([
513
513
  "headColor",
514
514
  "skeletonColor",
515
515
  "trailStyle",
516
- "headRadius"
516
+ "headRadius",
517
+ "trailWidth"
517
518
  ]);
518
519
  function validateRenderOptions(partial) {
519
520
  for (const key of Object.keys(partial)) {
@@ -536,6 +537,9 @@ function validateRenderOptions(partial) {
536
537
  if (partial.headRadius !== void 0) {
537
538
  assertHeadRadius(partial.headRadius);
538
539
  }
540
+ if (partial.trailWidth !== void 0) {
541
+ assertTrailWidth(partial.trailWidth);
542
+ }
539
543
  }
540
544
  function assertTrailColor(value) {
541
545
  if (typeof value === "string") {
@@ -605,6 +609,18 @@ function assertHeadRadius(value) {
605
609
  );
606
610
  }
607
611
  }
612
+ function assertTrailWidth(value) {
613
+ if (typeof value !== "number") {
614
+ throw new TypeError(
615
+ `[sarmal] setRenderOptions: trailWidth must be a number, got ${JSON.stringify(value)}`
616
+ );
617
+ }
618
+ if (!Number.isFinite(value) || value <= 0) {
619
+ throw new TypeError(
620
+ `[sarmal] setRenderOptions: trailWidth must be a finite positive number, got ${value}`
621
+ );
622
+ }
623
+ }
608
624
  function resolveTrailMainColor(trailColor) {
609
625
  return typeof trailColor === "string" ? trailColor : trailColor[0];
610
626
  }
@@ -673,7 +689,14 @@ function createRenderer(options) {
673
689
  setupCanvas();
674
690
  let logicalWidth = canvas.width / dpr;
675
691
  let logicalHeight = canvas.height / dpr;
692
+ if (options.headRadius !== void 0) {
693
+ validateRenderOptions({ headRadius: options.headRadius });
694
+ }
695
+ if (options.trailWidth !== void 0) {
696
+ validateRenderOptions({ trailWidth: options.trailWidth });
697
+ }
676
698
  let headRadius = options.headRadius ?? getHeadDotRadius(logicalWidth, logicalHeight);
699
+ let trailWidth = options.trailWidth ?? 1;
677
700
  let skeleton = [];
678
701
  let skeletonCanvas = null;
679
702
  let trail = [];
@@ -767,7 +790,9 @@ function createRenderer(options) {
767
790
  i,
768
791
  trailCount,
769
792
  toX,
770
- toY
793
+ toY,
794
+ TRAIL_MIN_WIDTH * trailWidth,
795
+ TRAIL_MAX_WIDTH * trailWidth
771
796
  );
772
797
  if (trailStyle === "default") {
773
798
  ctx.fillStyle = `rgba(${trailSolidRgb},${opacity})`;
@@ -925,6 +950,9 @@ function createRenderer(options) {
925
950
  if (partial.headRadius !== void 0) {
926
951
  headRadius = partial.headRadius;
927
952
  }
953
+ if (partial.trailWidth !== void 0) {
954
+ trailWidth = partial.trailWidth;
955
+ }
928
956
  if (userHeadColor === null) {
929
957
  headColor = resolveHeadColor(trailColor, trailStyle);
930
958
  } else {
@@ -1023,7 +1051,14 @@ function createSVGRenderer(options) {
1023
1051
  const svgTrailMinWidth = TRAIL_MIN_WIDTH * viewSize / containerPx;
1024
1052
  const svgTrailMaxWidth = TRAIL_MAX_WIDTH * viewSize / containerPx;
1025
1053
  const svgSkeletonStrokeWidth = String(SKELETON_STROKE_WIDTH_PX * viewSize / containerPx);
1054
+ if (options.headRadius !== void 0) {
1055
+ validateRenderOptions({ headRadius: options.headRadius });
1056
+ }
1057
+ if (options.trailWidth !== void 0) {
1058
+ validateRenderOptions({ trailWidth: options.trailWidth });
1059
+ }
1026
1060
  headRadius = options.headRadius ?? SVG_DEFAULT_HEAD_RADIUS;
1061
+ let trailWidth = options.trailWidth ?? 1;
1027
1062
  container.setAttribute("viewBox", `0 0 ${viewSize} ${viewSize}`);
1028
1063
  container.setAttribute("role", "img");
1029
1064
  container.setAttribute("aria-label", ariaLabel);
@@ -1118,8 +1153,8 @@ function createSVGRenderer(options) {
1118
1153
  trailCount,
1119
1154
  px,
1120
1155
  py,
1121
- svgTrailMinWidth,
1122
- svgTrailMaxWidth
1156
+ svgTrailMinWidth * trailWidth,
1157
+ svgTrailMaxWidth * trailWidth
1123
1158
  );
1124
1159
  const d = `M${l0x.toFixed(2)} ${l0y.toFixed(2)} L${l1x.toFixed(2)} ${l1y.toFixed(2)} L${r1x.toFixed(2)} ${r1y.toFixed(2)} L${r0x.toFixed(2)} ${r0y.toFixed(2)} Z`;
1125
1160
  trailPaths[i].setAttribute("d", d);
@@ -1311,6 +1346,9 @@ function createSVGRenderer(options) {
1311
1346
  headRadius = partial.headRadius;
1312
1347
  headCircle.setAttribute("r", String(headRadius));
1313
1348
  }
1349
+ if (partial.trailWidth !== void 0) {
1350
+ trailWidth = partial.trailWidth;
1351
+ }
1314
1352
  if (userHeadColor === null) {
1315
1353
  headColor = resolveHeadColor(trailColor, trailStyle);
1316
1354
  } else {