/** * figma-exact squircle path generator * * Generates SVG path data for polygons with Figma-style corner rounding * and corner smoothing (squircles). The construction was reverse-engineered * from ground-truth SVG exports produced by Figma itself and verified to * match Figma's output within 0.01px across 60°, 90°, and 120° corners, * per-corner radii, and budget-clamped cases. * * Math summary — per corner with opening angle φ, turn = π − φ, * radius R, smoothing ξ (Figma's `cornerSmoothing`, 0–1): * * q = R / tan(φ/2) tangent length of plain rounding * p = (1 + ξ) · q total edge length consumed * β = (turn / 2) · ξ heading change per smoothing ramp * t = R · tan(β/2) tangent length at ramp/arc junction * arc sweep = turn · (1 − ξ) the circular arc shrinks with ξ * * Smoothing cubic (distances from the vertex along the edge line): * P0 @ p, P1 @ p − a, P2 @ q − t (a = 2b, a + b = p − q + t) * P3 = trimmed-arc endpoint. Mirrored on the outgoing side. * * Budget clamp (verified against Figma): clamp q to the edge budget * first (reducing the radius), then clamp ξ so p fits: ξ_eff = p/q − 1. */ interface SquirclePoint { x: number; y: number; /** Corner radius in px. Falls back to `defaultRadius`. */ radius?: number; /** Corner smoothing ξ ∈ [0, 1] (Figma's cornerSmoothing). Falls back to `defaultSmoothness`. */ smoothness?: number; } interface SquircleOptions { /** Radius used for points that don't specify their own. Default 0. */ defaultRadius?: number; /** Smoothing used for points that don't specify their own. Default 0. */ defaultSmoothness?: number; /** Decimal places in the output path. Default 2. */ precision?: number; } interface SquircleRectOptions { width: number; height: number; /** X offset of the rect. Default 0. */ x?: number; /** Y offset of the rect. Default 0. */ y?: number; /** Uniform corner radius. Individual corners override this. */ cornerRadius?: number; topLeftRadius?: number; topRightRadius?: number; bottomRightRadius?: number; bottomLeftRadius?: number; /** Figma's cornerSmoothing, ξ ∈ [0, 1]. Default 0. */ cornerSmoothing?: number; /** Decimal places in the output path. Default 2. */ precision?: number; } /** * Generate an SVG path (`d` attribute) for a closed polygon with * Figma-style corner rounding + smoothing. Each point may carry its * own `radius` and `smoothness`. */ declare function getSquirclePath(points: SquirclePoint[], options?: SquircleOptions): string; /** * Convenience wrapper for rectangles — mirrors Figma's rectangle * properties (`cornerRadius`, `cornerSmoothing`, per-corner radii). */ declare function getSquircleRectPath(options: SquircleRectOptions): string; export { type SquircleOptions, type SquirclePoint, type SquircleRectOptions, getSquirclePath, getSquircleRectPath };