Skip to content

Function: morphPolygon() ​

ts
function morphPolygon(
   poly, 
   radius, 
   n, 
   box
): Polygon;

poly with its corners rounded (by radius, or a radius per corner) as at least n points, laid out the same way whatever the radius: each corner gets a fixed number of points by how far the outline turns there (one per 10°, all on the vertex when it's sharp, spread along the arc when it's rounded), and the rest go along the edges by the sharp outline's edge lengths. So a tile morphs smoothly as its corner radius changes, as well as into other shapes (see resamplePolygon for the start point and direction). Shapes with too many corners for n (merged featured tiles, say) get more points: the next multiple of 24 that fits, so most tiles share one count and can morph into each other.

Parameters ​

ParameterType
polyPolygon
radiusnumber | readonly number[]
nnumber
boxRect

Returns ​

Polygon

Hat tiling and isohedral tilings after Craig S. Kaplan's hatviz and Tactile (BSD 3-Clause).