canvu-react 0.3.30 → 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 +55 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +55 -78
- package/dist/index.js.map +1 -1
- package/dist/native.cjs +55 -78
- package/dist/native.cjs.map +1 -1
- package/dist/native.js +55 -78
- package/dist/native.js.map +1 -1
- package/dist/react.cjs +57 -79
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +57 -79
- 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 +54 -77
- package/dist/tldraw.cjs.map +1 -1
- package/dist/tldraw.js +54 -77
- package/dist/tldraw.js.map +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -286,40 +286,29 @@ 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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
for (let index = 1; index <= count; index += 1) {
|
|
316
|
-
const y0 = startY + step * (index - 1);
|
|
317
|
-
const y1 = index === count ? endY : startY + step * index;
|
|
318
|
-
const cy = (y0 + y1) / 2;
|
|
319
|
-
segments.push(
|
|
320
|
-
`Q${svgNumber(controlX)} ${svgNumber(cy)} ${svgNumber(x)} ${svgNumber(y1)}`
|
|
321
|
-
);
|
|
322
|
-
}
|
|
291
|
+
const rounded = Math.round(value * 100) / 100;
|
|
292
|
+
return Number.isInteger(rounded) ? String(rounded) : String(rounded);
|
|
293
|
+
}
|
|
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;
|
|
304
|
+
}
|
|
305
|
+
function pointOnSuperellipse(centerX, centerY, radiusX, radiusY, theta, exponent) {
|
|
306
|
+
const cosTheta = Math.cos(theta);
|
|
307
|
+
const sinTheta = Math.sin(theta);
|
|
308
|
+
return [
|
|
309
|
+
centerX + Math.sign(cosTheta) * radiusX * Math.abs(cosTheta) ** (2 / exponent),
|
|
310
|
+
centerY + Math.sign(sinTheta) * radiusY * Math.abs(sinTheta) ** (2 / exponent)
|
|
311
|
+
];
|
|
323
312
|
}
|
|
324
313
|
function buildRectSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
325
314
|
return `<rect width="${width}" height="${height}" fill="none" stroke="${style.stroke}" stroke-width="${style.strokeWidth}" rx="4"${strokeOpacityAttr(style)} />`;
|
|
@@ -333,53 +322,41 @@ function buildArchitecturalCloudPathD(width, height, strokeWidth = DEFAULT_STROK
|
|
|
333
322
|
const w = Math.max(0, width);
|
|
334
323
|
const h = Math.max(0, height);
|
|
335
324
|
if (w <= 0 || h <= 0) return "";
|
|
336
|
-
const inset = Math.
|
|
337
|
-
const
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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`
|
|
325
|
+
const inset = Math.max(0.5, strokeWidth / 2);
|
|
326
|
+
const outerRx = Math.max(0, w / 2 - inset);
|
|
327
|
+
const outerRy = Math.max(0, h / 2 - inset);
|
|
328
|
+
if (outerRx <= 0 || outerRy <= 0) return "";
|
|
329
|
+
const baseExponent = 3.6;
|
|
330
|
+
const amplitude = Math.min(
|
|
331
|
+
outerRx * 0.45,
|
|
332
|
+
outerRy * 0.45,
|
|
333
|
+
Math.max(2, Math.min(7, Math.min(w, h) * 0.035))
|
|
382
334
|
);
|
|
335
|
+
const innerRx = Math.max(0, outerRx - amplitude);
|
|
336
|
+
const innerRy = Math.max(0, outerRy - amplitude);
|
|
337
|
+
const scallopCount = architecturalCloudScallopCount(innerRx, innerRy, amplitude);
|
|
338
|
+
const angleStep = Math.PI * 2 / scallopCount;
|
|
339
|
+
const cx = w / 2;
|
|
340
|
+
const cy = h / 2;
|
|
341
|
+
const startAngle = -Math.PI / 2;
|
|
342
|
+
const pointOnArchitecturalCloud = (theta, radiusX, radiusY) => pointOnSuperellipse(cx, cy, radiusX, radiusY, theta, baseExponent);
|
|
343
|
+
const [startX, startY] = pointOnArchitecturalCloud(startAngle, innerRx, innerRy);
|
|
344
|
+
const segments = [`M${svgNumber(startX)} ${svgNumber(startY)}`];
|
|
345
|
+
for (let index = 0; index < scallopCount; index += 1) {
|
|
346
|
+
const segmentStart = startAngle + index * angleStep;
|
|
347
|
+
const segmentMid = segmentStart + angleStep / 2;
|
|
348
|
+
const segmentEnd = segmentStart + angleStep;
|
|
349
|
+
const [controlX, controlY] = pointOnArchitecturalCloud(
|
|
350
|
+
segmentMid,
|
|
351
|
+
outerRx,
|
|
352
|
+
outerRy
|
|
353
|
+
);
|
|
354
|
+
const [endX, endY] = pointOnArchitecturalCloud(segmentEnd, innerRx, innerRy);
|
|
355
|
+
segments.push(
|
|
356
|
+
`Q${svgNumber(controlX)} ${svgNumber(controlY)} ${svgNumber(endX)} ${svgNumber(endY)}`
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
segments.push("Z");
|
|
383
360
|
return segments.join(" ");
|
|
384
361
|
}
|
|
385
362
|
function buildArchitecturalCloudSvg(width, height, style = DEFAULT_STROKE_STYLE) {
|
|
@@ -3136,6 +3113,7 @@ function ShapeContextMenu({
|
|
|
3136
3113
|
}
|
|
3137
3114
|
return reactDom.createPortal(menu, document.body);
|
|
3138
3115
|
}
|
|
3116
|
+
var architecturalCloudIconPath = "M11 3 Q15.72 1.11 16.44 3.31 Q19.25 2.05 18.39 4.28 Q20.81 4.17 19 7 Q20.81 9.83 18.39 9.72 Q19.25 11.95 16.44 10.69 Q15.72 12.89 11 11 Q6.28 12.89 5.56 10.69 Q2.75 11.95 3.61 9.72 Q1.19 9.83 3 7 Q1.19 4.17 3.61 4.28 Q2.75 2.05 5.56 3.31 Q6.28 1.11 11 3 Z";
|
|
3139
3117
|
var base = {
|
|
3140
3118
|
width: 20,
|
|
3141
3119
|
height: 20,
|
|
@@ -3167,7 +3145,7 @@ function IconEllipse(props) {
|
|
|
3167
3145
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("ellipse", { cx: "12", cy: "12", rx: "9", ry: "6" }) });
|
|
3168
3146
|
}
|
|
3169
3147
|
function IconArchitecturalCloud(props) {
|
|
3170
|
-
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d:
|
|
3148
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: architecturalCloudIconPath, transform: "translate(1 5)" }) });
|
|
3171
3149
|
}
|
|
3172
3150
|
function IconLine(props) {
|
|
3173
3151
|
return /* @__PURE__ */ jsxRuntime.jsx("svg", { ...base, ...props, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx("line", { x1: "5", y1: "19", x2: "19", y2: "5" }) });
|