Standard CSS border-radius snaps straight edges directly into circular arcs. Learn why Apple uses G2 continuous superellipses, how the Lamé curve works, and how to render clean rounded assets.
- Optimized for Squircle vs rounded rectangle 2026
- Optimized for Apple squircle formula
- Optimized for G2 curvature continuity css
Definition & Core Difference
A rounded rectangle joins straight edges to fixed circular arcs with G1 continuity, creating an abrupt jump in curvature where the lines meet. A squircle is a mathematical superellipse ($|x/a|^n + |y/b|^n = 1$) that achieves G2 continuity: the curvature accelerates continuously from zero into the turn, eliminating optical kinks and matching the organic curvature of Apple iOS icons and hardware bezels.
1. The Continuity Hierarchy: G0, G1, and G2 Explained
In computer-aided industrial design and vector typography, transitions between line segments are classified by their degree of geometric smoothness:
| Class | Derivative Match | Real-World Geometry | Optical Behavior |
|---|---|---|---|
| G0 (Positional) | Endpoints touch: $P_1 = P_2$ | Sharp, unrounded 90-degree corner. | Hard acute angle. Zero curvature transition. |
| G1 (Tangential) | First derivative matches: $f'(x_1) = f'(x_2)$ | Standard CSS border-radius. Straight lines meet circular arcs. |
Visible "kink" at the junction where curvature jumps instantaneously from 0 to $1/r$. |
| G2 (Curvature) | Second derivative matches: $f''(x_1) = f''(x_2)$ | Apple Superellipse (Lamé curve, $n approx 4.5 ext{--}5$). | Liquid, organic curve. Curvature ramps smoothly from zero into the corner apex. |
Vector Comparison: G1 Tangent vs. G2 Curvature Continuity
Notice how the G1 curve on the left has an explicit corner break point at [200, 90], while the G2 curve on the right bends progressively.
2. The Lamé Curve Formula: Decoding Exponent "n"
In 1818, French mathematician Gabriel Lamé published the general equation for superellipses:
When tuning geometric shapes for digital devices, the exponent $n$ controls the profile:
- $n = 2$: Standard circle (or ellipse when $a eq b$). Constant, uniform curvature.
- $n = 4$: Classic mathematical Squircle. Flat midsections with soft continuous transitions.
- $n approx 4.5 ext{--}5$: Apple's iOS icon profile. Preserves straight edges across 60% of the bounding box while softening the corner approach.
- $n o infty$: Pushes coordinates completely to the bounding corners, resulting in an unrounded rectangle.
3. Why CSS Cannot Do This Natively (And Why Houdini Failed)
Modern browsers still lack a native border-corner-shape: squircle property. Developers have experimented with three alternative implementations, each carrying concrete production trade-offs:
1. CSS Paint API (Houdini)
A custom worklet script computes the Lamé curve in JS and draws it onto an element's background. Unfortunately, Safari has refused to implement Houdini Paint, and Firefox hides it behind flags. A CSS trick that breaks on iPhones fails the core audience.
2. SVG clip-path
You map cubic Bézier points to approximate a superellipse and clip HTML containers. It works, but it breaks GPU compositing during scroll, blurs fine font sub-pixels, and requires fixed aspect ratios.
3. Pre-Rendered Canvas PNG
Instead of demanding client CPUs recompute differential geometry on every DOM reflow, you rasterize the curve into a transparent 32-bit PNG asset. Zero runtime layout tax. Flawless rendering on every mobile and desktop browser.
That third approach is what the RapidDoc Image Radiator implements. The engine draws your source photo onto an offscreen canvas, clips the border using cubic Bézier splines calibrated to $n=4.5$, and exports a clean transparent PNG.
4. Production Code: Vanilla JavaScript Canvas Squircle Clipper
If you want to render a true G2-approximated squircle directly inside an HTML5 <canvas> element without third-party libraries, use this cubic Bézier curve implementation:
function drawSquirclePath(ctx, x, y, width, height, r) {
// r: corner radius scalar (e.g. 0.22 * width for Apple icons)
const a = width / 2;
const b = height / 2;
const k = 0.5522847498; // Standard circle kappa
// Shift control points outward to simulate n=4.5 curvature acceleration
const squircleOffset = r * 0.35;
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + width - r, y);
ctx.bezierCurveTo(x + width - squircleOffset, y, x + width, y + squircleOffset, x + width, y + r);
ctx.lineTo(x + width, y + height - r);
ctx.bezierCurveTo(x + width, y + height - squircleOffset, x + width - squircleOffset, y + height, x + width - r, y + height);
ctx.lineTo(x + r, y + height);
ctx.bezierCurveTo(x + squircleOffset, y + height, x, y + height - squircleOffset, x, y + height - r);
ctx.lineTo(x, y + r);
ctx.bezierCurveTo(x, y + squircleOffset, x + squircleOffset, y, x + r, y);
ctx.closePath();
}
5. Dual-Layer Ambient Occlusion Shadows
Rounding an asset without giving it depth leaves it looking flat. But applying a harsh black drop shadow (0 10px 20px rgba(0,0,0,0.5)) looks dated. Real light in a physical room scatters into two distinct shadow layers:
Physics of Natural Drop Shadows: Umbra vs. Penumbra
When you combine G2 squircle clipping with dual-layer ambient occlusion, your screen captures feel like tangible physical cards floating above the page. In social feeds, this tactile quality stops users from scrolling past.
6. Asymmetrical Radii & Screenshot Window Chrome
Decoupling individual corners allows you to build directional UI shapes:
| Layout Style | Corner Values (TL / TR / BR / BL) | Production Application |
|---|---|---|
| The Docked Tab | 24px / 24px / 0px / 0px | Modal headers and bottom-docked dashboard panels. |
| The Chat Pointer | 28px / 28px / 4px / 28px | Testimonial quotes and message bubbles where the bottom-right corner acts as a speaking cue. |
| The Diagonal Leaf | 48px / 0px / 48px / 0px | Editorial banners and consumer marketing carousels that break square grid fatigue. |
For software documentation and product launches, the Image Radiator lets you wrap any screenshot in simulated macOS window chrome with red (#FF5F56), yellow (#FFBD2E), and green (#27C93F) traffic-light controls. All rendered locally in your browser memory.
Connected Downstream Utilities
Need to scale your rounded mockup to exact social banner dimensions? Pass it to our Smart Image Resizer. Need to shave 80% off the transparent PNG file size before web deployment? Optimize it using the Smart Image Compressor.
System Sovereignty & Engineering
Edge Computing
100% Client-side processing. Your data never leaves your browser sandbox, ensuring absolute compliance with US privacy mandates.
Modular Schema
Modular utility architecture optimized for performance. Low-latency WASM kernels provide near-native speeds for complex transformations.
Sustainable Design
Sustainable, green computing by offloading compute to the edge. Verified zero-server storage (ZSS) for professional-grade security.