canvu-react 0.3.30 → 0.3.31
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 +44 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -77
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +44 -77
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +44 -77
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +46 -78
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +46 -78
- package/dist/react.js.map +1 -1
- package/dist/realtime.cjs +2 -1
- package/dist/realtime.cjs.map +1 -1
- package/dist/realtime.js +2 -1
- package/dist/realtime.js.map +1 -1
- package/dist/tldraw.cjs +44 -77
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.js +44 -77
- package/dist/tldraw.js.map +1 -1
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -279,40 +279,21 @@ function resolveStrokeStyle(item) {
|
|
|
279
279
|
function strokeOpacityAttr(style) {
|
|
280
280
|
return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
|
|
281
281
|
}
|
|
282
|
-
function clampNumber(value, min, max) {
|
|
283
|
-
return Math.min(max, Math.max(min, value));
|
|
284
|
-
}
|
|
285
282
|
function svgNumber(value) {
|
|
286
283
|
if (!Number.isFinite(value)) return "0";
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
function architecturalCloudScallopCount(length, depth) {
|
|
290
|
-
if (length <= 1e-6) return 0;
|
|
291
|
-
return Math.max(1, Math.round(length / Math.max(depth * 2.05, 8)));
|
|
292
|
-
}
|
|
293
|
-
function appendHorizontalScallops(segments, startX, endX, y, controlY, count) {
|
|
294
|
-
if (count <= 0) return;
|
|
295
|
-
const step = (endX - startX) / count;
|
|
296
|
-
for (let index = 1; index <= count; index += 1) {
|
|
297
|
-
const x0 = startX + step * (index - 1);
|
|
298
|
-
const x1 = index === count ? endX : startX + step * index;
|
|
299
|
-
const cx = (x0 + x1) / 2;
|
|
300
|
-
segments.push(
|
|
301
|
-
`Q${svgNumber(cx)} ${svgNumber(controlY)} ${svgNumber(x1)} ${svgNumber(y)}`
|
|
302
|
-
);
|
|
303
|
-
}
|
|
284
|
+
const rounded = Math.round(value * 100) / 100;
|
|
285
|
+
return Number.isInteger(rounded) ? String(rounded) : String(rounded);
|
|
304
286
|
}
|
|
305
|
-
function
|
|
306
|
-
if (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
287
|
+
function approximateEllipsePerimeter(rx, ry) {
|
|
288
|
+
if (rx <= 0 || ry <= 0) return 0;
|
|
289
|
+
return Math.PI * (3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)));
|
|
290
|
+
}
|
|
291
|
+
function architecturalCloudScallopCount(rx, ry, amplitude) {
|
|
292
|
+
const perimeter = approximateEllipsePerimeter(rx, ry);
|
|
293
|
+
const targetScallopLength = Math.max(10, amplitude * 2);
|
|
294
|
+
let count = Math.max(12, Math.round(perimeter / targetScallopLength));
|
|
295
|
+
if (count % 2 === 1) count += 1;
|
|
296
|
+
return count;
|
|
316
297
|
}
|
|
317
298
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
318
299
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
@@ -326,53 +307,39 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
|
|
|
326
307
|
const w = Math.max(0, width);
|
|
327
308
|
const h = Math.max(0, height);
|
|
328
309
|
if (w <= 0 || h <= 0) return "";
|
|
329
|
-
const inset = Math.
|
|
330
|
-
const
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
const
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const maxDepth = Math.max(0.5, Math.min(innerW, innerH) * 0.18);
|
|
338
|
-
const depth = clampNumber(Math.min(w, h) * 0.08, 2, Math.min(12, maxDepth));
|
|
339
|
-
const corner = Math.min(depth * 1.2, innerW / 2, innerH / 2);
|
|
340
|
-
const topStart = x0 + corner;
|
|
341
|
-
const topEnd = x1 - corner;
|
|
342
|
-
const rightStart = y0 + corner;
|
|
343
|
-
const rightEnd = y1 - corner;
|
|
344
|
-
const bottomStart = x1 - corner;
|
|
345
|
-
const bottomEnd = x0 + corner;
|
|
346
|
-
const leftStart = y1 - corner;
|
|
347
|
-
const leftEnd = y0 + corner;
|
|
348
|
-
const topCount = architecturalCloudScallopCount(topEnd - topStart, depth);
|
|
349
|
-
const rightCount = architecturalCloudScallopCount(rightEnd - rightStart, depth);
|
|
350
|
-
const bottomCount = architecturalCloudScallopCount(bottomStart - bottomEnd, depth);
|
|
351
|
-
const leftCount = architecturalCloudScallopCount(leftStart - leftEnd, depth);
|
|
352
|
-
const segments = [`M${svgNumber(topStart)} ${svgNumber(y0)}`];
|
|
353
|
-
appendHorizontalScallops(segments, topStart, topEnd, y0, y0 + depth, topCount);
|
|
354
|
-
segments.push(
|
|
355
|
-
`Q${svgNumber(x1)} ${svgNumber(y0)} ${svgNumber(x1)} ${svgNumber(rightStart)}`
|
|
356
|
-
);
|
|
357
|
-
appendVerticalScallops(segments, rightStart, rightEnd, x1, x1 - depth, rightCount);
|
|
358
|
-
segments.push(
|
|
359
|
-
`Q${svgNumber(x1)} ${svgNumber(y1)} ${svgNumber(bottomStart)} ${svgNumber(y1)}`
|
|
360
|
-
);
|
|
361
|
-
appendHorizontalScallops(
|
|
362
|
-
segments,
|
|
363
|
-
bottomStart,
|
|
364
|
-
bottomEnd,
|
|
365
|
-
y1,
|
|
366
|
-
y1 - depth,
|
|
367
|
-
bottomCount
|
|
368
|
-
);
|
|
369
|
-
segments.push(
|
|
370
|
-
`Q${svgNumber(x0)} ${svgNumber(y1)} ${svgNumber(x0)} ${svgNumber(leftStart)}`
|
|
371
|
-
);
|
|
372
|
-
appendVerticalScallops(segments, leftStart, leftEnd, x0, x0 + depth, leftCount);
|
|
373
|
-
segments.push(
|
|
374
|
-
`Q${svgNumber(x0)} ${svgNumber(y0)} ${svgNumber(topStart)} ${svgNumber(y0)} Z`
|
|
310
|
+
const inset = Math.max(0.5, strokeWidth / 2);
|
|
311
|
+
const outerRx = Math.max(0, w / 2 - inset);
|
|
312
|
+
const outerRy = Math.max(0, h / 2 - inset);
|
|
313
|
+
if (outerRx <= 0 || outerRy <= 0) return "";
|
|
314
|
+
const amplitude = Math.min(
|
|
315
|
+
outerRx * 0.45,
|
|
316
|
+
outerRy * 0.45,
|
|
317
|
+
Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
|
|
375
318
|
);
|
|
319
|
+
const innerRx = Math.max(0, outerRx - amplitude);
|
|
320
|
+
const innerRy = Math.max(0, outerRy - amplitude);
|
|
321
|
+
const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
|
|
322
|
+
const angleStep = Math.PI * 2 / scallopCount;
|
|
323
|
+
const cx = w / 2;
|
|
324
|
+
const cy = h / 2;
|
|
325
|
+
const startAngle = -Math.PI / 2;
|
|
326
|
+
const pointOnEllipse = (theta, radiusX, radiusY) => [
|
|
327
|
+
cx + Math.cos(theta) * radiusX,
|
|
328
|
+
cy + Math.sin(theta) * radiusY
|
|
329
|
+
];
|
|
330
|
+
const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
|
|
331
|
+
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
332
|
+
for (let index = 0; index < scallopCount; index += 1) {
|
|
333
|
+
const segmentStart = startAngle + index * angleStep;
|
|
334
|
+
const segmentMid = segmentStart + angleStep / 2;
|
|
335
|
+
const segmentEnd = segmentStart + angleStep;
|
|
336
|
+
const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
|
|
337
|
+
const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
|
|
338
|
+
segments.push(
|
|
339
|
+
`Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
340
|
+
);
|
|
341
|
+
}
|
|
342
|
+
segments.push("Z");
|
|
376
343
|
return segments.join(" ");
|
|
377
344
|
}
|
|
378
345
|
function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
@@ -3129,6 +3096,7 @@ function ShapeContextMenu({
|
|
|
3129
3096
|
}
|
|
3130
3097
|
return createPortal(menu, document.body);
|
|
3131
3098
|
}
|
|
3099
|
+
var architecturalCloudIconPath = "M12 8.28 Q14.33 7.17 15.86 8.78 Q18.36 8.46 18.69 10.14 Q20.69 10.71 19.72 12 Q20.69 13.29 18.69 13.86 Q18.36 15.54 15.86 15.22 Q14.33 16.83 12 15.72 Q9.67 16.83 8.14 15.22 Q5.64 15.54 5.31 13.86 Q3.31 13.29 4.28 12 Q3.31 10.71 5.31 10.14 Q5.64 8.46 8.14 8.78 Q9.67 7.17 12 8.28 Z";
|
|
3132
3100
|
var base = {
|
|
3133
3101
|
width: 20,
|
|
3134
3102
|
height: 20,
|
|
@@ -3160,7 +3128,7 @@ function IconEllipse(props) {
|
|
|
3160
3128
|
return /* @__PURE__ */ jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsx("ellipse", { cx: "12", cy: "12", rx: "9", ry: "6" }) });
|
|
3161
3129
|
}
|
|
3162
3130
|
function IconArchitecturalCloud(props) {
|
|
3163
|
-
return /* @__PURE__ */ jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d:
|
|
3131
|
+
return /* @__PURE__ */ jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: architecturalCloudIconPath, transform: "translate(0 4)" }) });
|
|
3164
3132
|
}
|
|
3165
3133
|
function IconLine(props) {
|
|
3166
3134
|
return /* @__PURE__ */ jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsx("line", { x1: "5", y1: "19", x2: "19", y2: "5" }) });
|