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