Skip to content

@technobuddha > library > Geometry > Polygon

Function: star()

ts
function star(
   sides: number, 
   outer: number, 
   inner: number, 
   options: OriginOptions): Polygon;

Defined in: star.ts:29

Generates a star-shaped polygon.

Parameters

ParameterTypeDefault valueDescription
sidesnumber3The number of points (arms) of the star. Must be at least 3.
outernumber1The radius from the origin to the outer vertices (tips) of the star.
innernumber...The radius from the origin to the inner vertices (indentations) of the star. Defaults to half of outer.
optionsOriginOptions{}see OriginOptions

Returns

Polygon

A star shaped polygon.

Throws

TypeError If sides is less than 3.

Example

typescript
star(4, 2, 1);
// [
//   { x: 2, y: 0 },
//   { x: √2/2, y: √2/2 },
//   { x: 0, y: 2 },
//   { x: -√2/2, y: √2/2 },
//   { x: -2, y: 0 },
//   { x: -√2/2, y: -√2/2 },
//   { x: 0, y: -2 },
//   { x: √2/2, y: -√2/2 }
// ]