CompGeoJS Star Shape

compgeojs-blog

I just added a Star shape to the CompGeoJS library that can be defined by the usual bounding rectangle and two additional parameters. A Star shape is typically defined by a number of points that are drawn with ‘spokes’ that taper to a point that is computed in a similar manner to a regular n-gon.

As the thickness parameter approaches zero, the Star degenerates into a number of linear spokes that extend from the centroid of the bounding rectangle.  As the thickness parameter increases, the inner spokes increase in thickness and the bounding circle for the interior increases in radius.

The thickness parameter can also be set to values greater than one.  This bulges the Star shape so that the outer bounding circle transforms into a bound on interior of the Star shape. This feature allows quite a bit of design flexibility, including the ability to create cool shapes like Ninja Stars.

So, I want to see a cool Stickman fighting animation with lots of Ninja Stars :)

As always, the supporting code is written with ease of readability in mind and is not minimized or obfuscated in any way.

View CompGeoJS Project

View Star Shape Demo

Enjoy!


Comments are closed.