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.cjs
CHANGED
|
@@ -286,40 +286,21 @@ function resolveStrokeStyle(item) {
|
|
|
286
286
|
function strokeOpacityAttr(style) {
|
|
287
287
|
return style.strokeOpacity != null ? ` stroke-opacity="${style.strokeOpacity}"` : "";
|
|
288
288
|
}
|
|
289
|
-
function clampNumber(value, min, max) {
|
|
290
|
-
return Math.min(max, Math.max(min, value));
|
|
291
|
-
}
|
|
292
289
|
function svgNumber(value) {
|
|
293
290
|
if (!Number.isFinite(value)) return "0";
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
function architecturalCloudScallopCount(length, depth) {
|
|
297
|
-
if (length <= 1e-6) return 0;
|
|
298
|
-
return Math.max(1, Math.round(length / Math.max(depth * 2.05, 8)));
|
|
299
|
-
}
|
|
300
|
-
function appendHorizontalScallops(segments, startX, endX, y, controlY, count) {
|
|
301
|
-
if (count <= 0) return;
|
|
302
|
-
const step = (endX - startX) / count;
|
|
303
|
-
for (let index = 1; index <= count; index += 1) {
|
|
304
|
-
const x0 = startX + step * (index - 1);
|
|
305
|
-
const x1 = index === count ? endX : startX + step * index;
|
|
306
|
-
const cx = (x0 + x1) / 2;
|
|
307
|
-
segments.push(
|
|
308
|
-
`Q${svgNumber(cx)} ${svgNumber(controlY)} ${svgNumber(x1)} ${svgNumber(y)}`
|
|
309
|
-
);
|
|
310
|
-
}
|
|
291
|
+
const rounded = Math.round(value * 100) / 100;
|
|
292
|
+
return Number.isInteger(rounded) ? String(rounded) : String(rounded);
|
|
311
293
|
}
|
|
312
|
-
function
|
|
313
|
-
if (
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
}
|
|
294
|
+
function approximateEllipsePerimeter(rx, ry) {
|
|
295
|
+
if (rx <= 0 || ry <= 0) return 0;
|
|
296
|
+
return Math.PI * (3 * (rx + ry) - Math.sqrt((3 * rx + ry) * (rx + 3 * ry)));
|
|
297
|
+
}
|
|
298
|
+
function architecturalCloudScallopCount(rx, ry, amplitude) {
|
|
299
|
+
const perimeter = approximateEllipsePerimeter(rx, ry);
|
|
300
|
+
const targetScallopLength = Math.max(10, amplitude * 2);
|
|
301
|
+
let count = Math.max(12, Math.round(perimeter / targetScallopLength));
|
|
302
|
+
if (count % 2 === 1) count += 1;
|
|
303
|
+
return count;
|
|
323
304
|
}
|
|
324
305
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
325
306
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
@@ -333,53 +314,39 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
|
|
|
333
314
|
const w = Math.max(0, width);
|
|
334
315
|
const h = Math.max(0, height);
|
|
335
316
|
if (w <= 0 || h <= 0) return "";
|
|
336
|
-
const inset = Math.
|
|
337
|
-
const
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
const maxDepth = Math.max(0.5, Math.min(innerW, innerH) * 0.18);
|
|
345
|
-
const depth = clampNumber(Math.min(w, h) * 0.08, 2, Math.min(12, maxDepth));
|
|
346
|
-
const corner = Math.min(depth * 1.2, innerW / 2, innerH / 2);
|
|
347
|
-
const topStart = x0 + corner;
|
|
348
|
-
const topEnd = x1 - corner;
|
|
349
|
-
const rightStart = y0 + corner;
|
|
350
|
-
const rightEnd = y1 - corner;
|
|
351
|
-
const bottomStart = x1 - corner;
|
|
352
|
-
const bottomEnd = x0 + corner;
|
|
353
|
-
const leftStart = y1 - corner;
|
|
354
|
-
const leftEnd = y0 + corner;
|
|
355
|
-
const topCount = architecturalCloudScallopCount(topEnd - topStart, depth);
|
|
356
|
-
const rightCount = architecturalCloudScallopCount(rightEnd - rightStart, depth);
|
|
357
|
-
const bottomCount = architecturalCloudScallopCount(bottomStart - bottomEnd, depth);
|
|
358
|
-
const leftCount = architecturalCloudScallopCount(leftStart - leftEnd, depth);
|
|
359
|
-
const segments = [`M${svgNumber(topStart)} ${svgNumber(y0)}`];
|
|
360
|
-
appendHorizontalScallops(segments, topStart, topEnd, y0, y0 + depth, topCount);
|
|
361
|
-
segments.push(
|
|
362
|
-
`Q${svgNumber(x1)} ${svgNumber(y0)} ${svgNumber(x1)} ${svgNumber(rightStart)}`
|
|
363
|
-
);
|
|
364
|
-
appendVerticalScallops(segments, rightStart, rightEnd, x1, x1 - depth, rightCount);
|
|
365
|
-
segments.push(
|
|
366
|
-
`Q${svgNumber(x1)} ${svgNumber(y1)} ${svgNumber(bottomStart)} ${svgNumber(y1)}`
|
|
367
|
-
);
|
|
368
|
-
appendHorizontalScallops(
|
|
369
|
-
segments,
|
|
370
|
-
bottomStart,
|
|
371
|
-
bottomEnd,
|
|
372
|
-
y1,
|
|
373
|
-
y1 - depth,
|
|
374
|
-
bottomCount
|
|
375
|
-
);
|
|
376
|
-
segments.push(
|
|
377
|
-
`Q${svgNumber(x0)} ${svgNumber(y1)} ${svgNumber(x0)} ${svgNumber(leftStart)}`
|
|
378
|
-
);
|
|
379
|
-
appendVerticalScallops(segments, leftStart, leftEnd, x0, x0 + depth, leftCount);
|
|
380
|
-
segments.push(
|
|
381
|
-
`Q${svgNumber(x0)} ${svgNumber(y0)} ${svgNumber(topStart)} ${svgNumber(y0)} Z`
|
|
317
|
+
const inset = Math.max(0.5, strokeWidth / 2);
|
|
318
|
+
const outerRx = Math.max(0, w / 2 - inset);
|
|
319
|
+
const outerRy = Math.max(0, h / 2 - inset);
|
|
320
|
+
if (outerRx <= 0 || outerRy <= 0) return "";
|
|
321
|
+
const amplitude = Math.min(
|
|
322
|
+
outerRx * 0.45,
|
|
323
|
+
outerRy * 0.45,
|
|
324
|
+
Math.max(2, Math.min(8, Math.min(w, h) * 0.04))
|
|
382
325
|
);
|
|
326
|
+
const innerRx = Math.max(0, outerRx - amplitude);
|
|
327
|
+
const innerRy = Math.max(0, outerRy - amplitude);
|
|
328
|
+
const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
|
|
329
|
+
const angleStep = Math.PI * 2 / scallopCount;
|
|
330
|
+
const cx = w / 2;
|
|
331
|
+
const cy = h / 2;
|
|
332
|
+
const startAngle = -Math.PI / 2;
|
|
333
|
+
const pointOnEllipse = (theta, radiusX, radiusY) => [
|
|
334
|
+
cx + Math.cos(theta) * radiusX,
|
|
335
|
+
cy + Math.sin(theta) * radiusY
|
|
336
|
+
];
|
|
337
|
+
const [startX, startY] = pointOnEllipse(startAngle, innerRx, innerRy);
|
|
338
|
+
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
339
|
+
for (let index = 0; index < scallopCount; index += 1) {
|
|
340
|
+
const segmentStart = startAngle + index * angleStep;
|
|
341
|
+
const segmentMid = segmentStart + angleStep / 2;
|
|
342
|
+
const segmentEnd = segmentStart + angleStep;
|
|
343
|
+
const [controlX, controlY] = pointOnEllipse(segmentMid, outerRx, outerRy);
|
|
344
|
+
const [endX, endY] = pointOnEllipse(segmentEnd, innerRx, innerRy);
|
|
345
|
+
segments.push(
|
|
346
|
+
`Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
segments.push("Z");
|
|
383
350
|
return segments.join(" ");
|
|
384
351
|
}
|
|
385
352
|
function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
@@ -3136,6 +3103,7 @@ function ShapeContextMenu({
|
|
|
3136
3103
|
}
|
|
3137
3104
|
return reactDom.createPortal(menu, document.body);
|
|
3138
3105
|
}
|
|
3106
|
+
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";
|
|
3139
3107
|
var base = {
|
|
3140
3108
|
width: 20,
|
|
3141
3109
|
height: 20,
|
|
@@ -3167,7 +3135,7 @@ function IconEllipse(props) {
|
|
|
3167
3135
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("ellipse", { cx: "12", cy: "12", rx: "9", ry: "6" }) });
|
|
3168
3136
|
}
|
|
3169
3137
|
function IconArchitecturalCloud(props) {
|
|
3170
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d:
|
|
3138
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: architecturalCloudIconPath, transform: "translate(0 4)" }) });
|
|
3171
3139
|
}
|
|
3172
3140
|
function IconLine(props) {
|
|
3173
3141
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "5", y1: "19", x2: "19", y2: "5" }) });
|