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/native.cjs
CHANGED
|
@@ -365,6 +365,14 @@ function architecturalCloudScallopCount(rx, ry, amplitude) {
|
|
|
365
365
|
if (count % 2 === 1) count += 1;
|
|
366
366
|
return count;
|
|
367
367
|
}
|
|
368
|
+
function pointOnSuperellipse(centerX, centerY, radiusX, radiusY, theta, exponent) {
|
|
369
|
+
const cosTheta = Math.cos(theta);
|
|
370
|
+
const sinTheta = Math.sin(theta);
|
|
371
|
+
return [
|
|
372
|
+
centerX + Math.sign(cosTheta) * radiusX * Math.abs(cosTheta) ** (2 / exponent),
|
|
373
|
+
centerY + Math.sign(sinTheta) * radiusY * Math.abs(sinTheta) ** (2 / exponent)
|
|
374
|
+
];
|
|
375
|
+
}
|
|
368
376
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
369
377
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
370
378
|
}
|
|
@@ -381,10 +389,11 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
|
|
|
381
389
|
const outerRx = Math.max(0, w / 2 - inset);
|
|
382
390
|
const outerRy = Math.max(0, h / 2 - inset);
|
|
383
391
|
if (outerRx <= 0 || outerRy <= 0) return "";
|
|
392
|
+
const baseExponent = 3.6;
|
|
384
393
|
const amplitude = Math.min(
|
|
385
394
|
outerRx * 0.45,
|
|
386
395
|
outerRy * 0.45,
|
|
387
|
-
Math.max(2, Math.min(
|
|
396
|
+
Math.max(2, Math.min(7, Math.min(w, h) * 0.035))
|
|
388
397
|
);
|
|
389
398
|
const innerRx = Math.max(0, outerRx - amplitude);
|
|
390
399
|
const innerRy = Math.max(0, outerRy - amplitude);
|
|
@@ -393,18 +402,19 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
|
|
|
393
402
|
const cx = w / 2;
|
|
394
403
|
const cy = h / 2;
|
|
395
404
|
const startAngle = -Math.PI / 2;
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
cy + Math.sin(theta) * radiusY
|
|
399
|
-
];
|
|
400
|
-
const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
|
|
405
|
+
const pointOnArchitecturalCloud = (theta, radiusX, radiusY) => pointOnSuperellipse(cx, cy, radiusX, radiusY, theta, baseExponent);
|
|
406
|
+
const [startX, startY] = pointOnArchitecturalCloud(startAngle, innerRx, innerRy);
|
|
401
407
|
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
402
408
|
for (let index = 0; index < scallopCount; index += 1) {
|
|
403
409
|
const segmentStart = startAngle + index * angleStep;
|
|
404
410
|
const segmentMid = segmentStart + angleStep / 2;
|
|
405
411
|
const segmentEnd = segmentStart + angleStep;
|
|
406
|
-
const [controlX, controlY] =
|
|
407
|
-
|
|
412
|
+
const [controlX, controlY] = pointOnArchitecturalCloud(
|
|
413
|
+
segmentMid,
|
|
414
|
+
outerRx,
|
|
415
|
+
outerRy
|
|
416
|
+
);
|
|
417
|
+
const [endX, endY] = pointOnArchitecturalCloud(segmentEnd, innerRx, innerRy);
|
|
408
418
|
segments.push(
|
|
409
419
|
`Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
410
420
|
);
|