Skip to main content

superellipse

Generalized superellipse (Lamé curve) geometry for Python.

PyPI version Python versions License CI Documentation codecov

Overview

A superellipse (or Lamé curve) is defined by:

$$|x/a|^p + |y/b|^q = 1$$

This package provides tools for working with these curves:

  • Geometry: Points, tangents, normals, curvature
  • Discretization: Uniform, arc-length, or adaptive panel-based sampling
  • Signed distance: Fast SDF evaluation for level-set methods
  • Export: SVG paths, JSON, NumPy arrays
  • Special cases: Squircle (p=q=4), rounded rectangles, stadium curves

Installation

pip install superellipse

# With plotting support
pip install superellipse[plot]

# With SVG export
pip install superellipse[export]

# Everything
pip install superellipse[all]

Quick Start

from superellipse import Superellipse

# Create a squircle (p=4, like iOS icons)
curve = Superellipse(a=1.0, b=1.0, p=4)

# Sample 100 points
points = curve.sample(n=100)

# Get curvature at each point
kappa = curve.curvature(points)

# Export to SVG path
path_data = curve.to_svg_path(n=100)

CLI

# Plot a superellipse
superellipse plot --a 1 --b 0.8 --p 4 --output squircle.png

# Export to SVG
superellipse export --a 1 --b 1 --p 6 --format svg --output curve.svg

# Compute arc length
superellipse info --a 1 --b 1 --p 4

Use Cases

  • UI/UX Design: Squircles for app icons (iOS-style rounded rectangles)
  • CAD/CAM: Smooth corner profiles for machining
  • Graphics: Procedural shape generation
  • Scientific Computing: Boundary geometry for PDEs
  • Typography: Letterform design with smooth corners

API Reference

Superellipse(a, b, p, q=None)

Create a superellipse with semi-axes a, b and exponents p, q. If q is None, uses q=p (symmetric exponent).

Methods

Method Description
sample(n, method='uniform') Sample n points on the curve
curvature(points) Signed curvature at given points
normal(points) Outward unit normals
tangent(points) Unit tangent vectors
arc_length(t0=0, t1=2π) Arc length between parameter values
signed_distance(points) Signed distance from points to curve
to_svg_path(n=100) Export as SVG path data string
to_json() Export curve parameters as JSON

Sampling Methods

  • 'uniform': Uniform in parameter t ∈ [0, 2π]
  • 'arclength': Uniform in arc length
  • 'adaptive': Refine near high-curvature regions
  • 'panels': Panel-based with Gauss-Legendre nodes (for BIE)

License

MIT License. See LICENSE for details.

Metadata

Release files for superellipse 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for superellipse 0.8.0
File Size Uploaded Provenance Actions
superellipse-0.8.0.tar.gz 19.7 kB With provenance Details for superellipse-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for superellipse 0.8.0
File Interpreter ABI Platform Actions
superellipse-0.8.0-py3-none-any.whl Python 3 none any Details for superellipse-0.8.0-py3-none-any.whl

Total release size: 32.9 kB

Release files / superellipse-0.8.0.tar.gz

Download URL superellipse-0.8.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0e372e1ec65044dfb59f37d29750588fecdc407b9184c3fb0be78099f6b1a843
BLAKE2b-256 checksum
How to use checksums
2b31c5dee428f9e19028fe6855d0994875b29a3429023a876036e2dbfbb2f695
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 26, 2026.

Transparency log

Release files / superellipse-0.8.0-py3-none-any.whl

Download URL superellipse-0.8.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9dd0d3d6353dd64b54ca4928548056130bed0f59e2524a8a862a2df465c0a362
BLAKE2b-256 checksum
How to use checksums
e61fb17dedba06532819981195aaf4938546f3a2ae867ca7ac8098cbf6fadf1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 26, 2026.

Transparency log

Security for superellipse 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for superellipse-0.8.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page