Skip to main content

Stretch discs/circles into squares and squish squares into discs/circles

Project description is a Python utility for stretching circles into squares and squishing squares into circles. It requires Python 3.6 or later.


pip insall squircle


from squircle import to_circle, to_square
from PIL import Image

square = np.asarray('some-square-image.jpg'))
circle = to_circle(square)
and_back_to_square = to_square(circle)

there's 3 stretching methods you can choose from

>>> from squircle import methods
>>> list(methods.keys())
['fgs', 'stretch', 'elliptical']
>>> circle = to_circle(square, method='elliptical')

Stretching methods

Fernández-Guasti squircle (fgs)

The Fernández-Guasti squircle is used by default.

Simple Stretching (stretch)

This method just linearly stretches each point radially so that the rim of the circle matches the rim of the square.

Elliptical grid mapping (elliptical)

"The way I went about this was to think of a line of constant x (as well as a line of constant y) getting mapped to an ellipse in the circle"

Schwarz-Christoffel conformal mapping

raise NotImplementedError. The math is difficult.

This code is converted from the C++ sources on Chamberlain Fong's blog posts, which (I think) is based on his paper Analytical Methods for Squaring the Disc by C Fong 2014.

Squircle doesn't handle ellipses/rectangles, this more recent paper should be useful: Elliptification of Rectangular Imagery by C Fong - ‎2017


After pip install tox you can run squircle's (limited) test set with


On Ubuntu, you also need the following dependencies for numpy and matplotlib

sudo apt install python3-dev libjpeg-dev zlib1g-dev libfreetype6-dev

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for squircle, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size squircle-0.2.0.tar.gz (4.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page