Visio Squircles

A couple weeks ago, I briefly glanced at my annoyingFacebook page and noticed that people were commenting on the “new look”, which I was fortunate enough to not notice.

What did catch my eye was a comment from one friend, who noted; “Hey, the new Facebook has squircles!” Then another replied; “Yes, squircles are so Web 2.0!”

Naturally I was put off by how folks try to Out-clever-two-point-oh each other on Facebook, but I was nonetheless curious about squircles, because they sounded…well…visual!

Scandal! It’s Not a True Squircle

So I immdiately set out to find out what a squircle was, and create a Visio version of one, if possible.

It turns out that squircles are a sort of rounded square.You can read about the details on Wikipedia, but I’ll summarize a squircle as a “circle to the fourth power”. Normally, you would describe a circle as being an x2+y2 kind of beast. A squircle would be what you get if you were to plot x4+y4.

The ShapeSheet behind each Visio shape is good at representing trigonometric curves, and you can use algebra to create expressions for each point in a shape. But it isn’t good at creating arbitrary curves and plotting innumerable points. So I had to come up with an approximation of r4, that could be expressed as circular arcs or elliptical arcs, or splines or nurbs.

Since my nurb- and spline-math is very rusty, I settled on creating a squircle from eight circular arcs, each arc tangent to the next. I think it looks pretty good, but see for yourself:

While the shape is composed of eight circular arcs, there are only three unique radii for these arcs, since the corner curves are all the same, the left and right sides are the same, and the top and bottom are the same.

In the illustration above, I’ve highlighted one set of unique arc-segments and colored them red, green and blue. They are all circular arcs, but they all have (potentially) different radii. Where they meet, they are tangent. So the red arc is tangent to the green arc, and the blue arc is tangent to the other end of the green arc.

Also shown are the radii for each arc. When the shape is stretched to be rectangular, the red and blue radii no longer remain the same. But the corner radii always remain the same–as specified by the shape’s user.

Creating the Squircle

To calculate the geometry for the shape, I had to resort to some lengthy, but not complicated, algebra and trigonometry. For this squircle shape, we choose a width and height, and we specify the arc and radius of the corners. These knowns, along with the constraint of tangency at each arc intersection make this a solvable system. Here’s the design- and calculation scribblings for the masochistic:

click to view larger image

The trick to translating complicated math like this into the ShapeSheet is to use User-defined cells. When you sketch out your geometry, give the important bits good-but-short names. As you do the algebra, notice any long-but-repeated expressions and turn them into variable- or constants to make your formulas shorter. Now all of the variables and constants become User-defined cells.

If you ignore the “User” bits, it starts to look a lot like eighth-grade algebra class, doesn’t it? The end-result of all this substitution and simplification is a very compact and clean Geometry section. This is what the actual arc-definitions look like for our squircle’s geometry-section:

click to view larger image

Using the Squircle Shape

When using this shape, we specify both the angle and the radius of the corner arcs (the green ones!) You do this via the Shape Data Window which you can access under the View menu.

We can see what happens as we vary the angle at the corner. Below, I’ve shown the shape as both a “squircle” (a square) and a “circtangle” (a rectangle). When the angle goes beyond 90°, things start to get interesting!

click to view larger image

Similarly, we can experiment with the radius at the corner. In the image below, I’ve expressed the radius as a function of the width of the shape, since absolute values wouldn’t tell you anything useful: