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