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/tldraw.js
CHANGED
|
@@ -233,6 +233,14 @@ function architecturalCloudScallopCount(rx, ry, amplitude) {
|
|
|
233
233
|
if (count % 2 === 1) count += 1;
|
|
234
234
|
return count;
|
|
235
235
|
}
|
|
236
|
+
function pointOnSuperellipse(centerX, centerY, radiusX, radiusY, theta, exponent) {
|
|
237
|
+
const cosTheta = Math.cos(theta);
|
|
238
|
+
const sinTheta = Math.sin(theta);
|
|
239
|
+
return [
|
|
240
|
+
centerX + Math.sign(cosTheta) * radiusX * Math.abs(cosTheta) ** (2 / exponent),
|
|
241
|
+
centerY + Math.sign(sinTheta) * radiusY * Math.abs(sinTheta) ** (2 / exponent)
|
|
242
|
+
];
|
|
243
|
+
}
|
|
236
244
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
237
245
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
238
246
|
}
|
|
@@ -249,10 +257,11 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
|
|
|
249
257
|
const outerRx = Math.max(0, w / 2 - inset);
|
|
250
258
|
const outerRy = Math.max(0, h / 2 - inset);
|
|
251
259
|
if (outerRx <= 0 || outerRy <= 0) return "";
|
|
260
|
+
const baseExponent = 3.6;
|
|
252
261
|
const amplitude = Math.min(
|
|
253
262
|
outerRx * 0.45,
|
|
254
263
|
outerRy * 0.45,
|
|
255
|
-
Math.max(2, Math.min(
|
|
264
|
+
Math.max(2, Math.min(7, Math.min(w, h) * 0.035))
|
|
256
265
|
);
|
|
257
266
|
const innerRx = Math.max(0, outerRx - amplitude);
|
|
258
267
|
const innerRy = Math.max(0, outerRy - amplitude);
|
|
@@ -261,18 +270,19 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
|
|
|
261
270
|
const cx = w / 2;
|
|
262
271
|
const cy = h / 2;
|
|
263
272
|
const startAngle = -Math.PI / 2;
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
cy + Math.sin(theta) * radiusY
|
|
267
|
-
];
|
|
268
|
-
const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
|
|
273
|
+
const pointOnArchitecturalCloud = (theta, radiusX, radiusY) => pointOnSuperellipse(cx, cy, radiusX, radiusY, theta, baseExponent);
|
|
274
|
+
const [startX, startY] = pointOnArchitecturalCloud(startAngle, innerRx, innerRy);
|
|
269
275
|
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
270
276
|
for (let index = 0; index < scallopCount; index += 1) {
|
|
271
277
|
const segmentStart = startAngle + index * angleStep;
|
|
272
278
|
const segmentMid = segmentStart + angleStep / 2;
|
|
273
279
|
const segmentEnd = segmentStart + angleStep;
|
|
274
|
-
const [controlX, controlY] =
|
|
275
|
-
|
|
280
|
+
const [controlX, controlY] = pointOnArchitecturalCloud(
|
|
281
|
+
segmentMid,
|
|
282
|
+
outerRx,
|
|
283
|
+
outerRy
|
|
284
|
+
);
|
|
285
|
+
const [endX, endY] = pointOnArchitecturalCloud(segmentEnd, innerRx, innerRy);
|
|
276
286
|
segments.push(
|
|
277
287
|
`Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
278
288
|
);
|