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 +18 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +18 -8
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +18 -8
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +20 -10
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +20 -10
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +2 -2
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +2 -2
- package/dist/realtime.js.map +1 -1
- package/dist/tldraw.cjs +18 -8
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.js +18 -8
- package/dist/tldraw.js.map +1 -1
- package/package.json +1 -1
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(
|
|
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
|
|
1086
|
-
|
|
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] =
|
|
1096
|
-
|
|
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
|
);
|