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