canvu-react 0.3.31 → 0.3.32

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.cjs CHANGED
@@ -1061,6 +1061,14 @@ function architecturalCloudScallopCount(rx, ry, amplitude) {
1061
1061
  if (count % 2 === 1) count += 1;
1062
1062
  return count;
1063
1063
  }
1064
+ function pointOnSuperellipse(centerX, centerY, radiusX, radiusY, theta, exponent) {
1065
+ const cosTheta = Math.cos(theta);
1066
+ const sinTheta = Math.sin(theta);
1067
+ return [
1068
+ centerX + Math.sign(cosTheta) * radiusX * Math.abs(cosTheta) ** (2 / exponent),
1069
+ centerY + Math.sign(sinTheta) * radiusY * Math.abs(sinTheta) ** (2 / exponent)
1070
+ ];
1071
+ }
1064
1072
  function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
1065
1073
  return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
1066
1074
  }
@@ -1077,10 +1085,11 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
1077
1085
  const outerRx = Math.max(0, w / 2 - inset);
1078
1086
  const outerRy = Math.max(0, h / 2 - inset);
1079
1087
  if (outerRx <= 0 || outerRy <= 0) return "";
1088
+ const baseExponent = 3.6;
1080
1089
  const amplitude = Math.min(
1081
1090
  outerRx * 0.45,
1082
1091
  outerRy * 0.45,
1083
- Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
1092
+ Math.max(2, Math.min(7, Math.min(w, h) * 0.035))
1084
1093
  );
1085
1094
  const innerRx = Math.max(0, outerRx - amplitude);
1086
1095
  const innerRy = Math.max(0, outerRy - amplitude);
@@ -1089,18 +1098,19 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
1089
1098
  const cx = w / 2;
1090
1099
  const cy = h / 2;
1091
1100
  const startAngle = -Math.PI / 2;
1092
- const pointOnEllipse = (theta, radiusX, radiusY) => [
1093
- cx + Math.cos(theta) * radiusX,
1094
- cy + Math.sin(theta) * radiusY
1095
- ];
1096
- const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
1101
+ const pointOnArchitecturalCloud = (theta, radiusX, radiusY) => pointOnSuperellipse(cx, cy, radiusX, radiusY, theta, baseExponent);
1102
+ const [startX, startY] = pointOnArchitecturalCloud(startAngle, innerRx, innerRy);
1097
1103
  const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
1098
1104
  for (let index = 0; index < scallopCount; index += 1) {
1099
1105
  const segmentStart = startAngle + index * angleStep;
1100
1106
  const segmentMid = segmentStart + angleStep / 2;
1101
1107
  const segmentEnd = segmentStart + angleStep;
1102
- const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
1103
- const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
1108
+ const [controlX, controlY] = pointOnArchitecturalCloud(
1109
+ segmentMid,
1110
+ outerRx,
1111
+ outerRy
1112
+ );
1113
+ const [endX, endY] = pointOnArchitecturalCloud(segmentEnd, innerRx, innerRy);
1104
1114
  segments.push(
1105
1115
  `Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
1106
1116
  );