Function starburst

Generates a starburst shape, returning an array of points. By default, initial point is top and horizontally-centred.

// Generate a starburst with four spikes
const pts = starburst(4, 100, 200);

points of two produces a lozenge shape. points of three produces a triangle shape. points of five is the familiar 'star' shape.

Note that the path will need to be closed back to the first point to enclose the shape.

const points = starburst(4, 100, 200);
Drawing.connectedPoints(ctx, pts, {loop: true, fillStyle: `orange`, strokeStyle: `red`});

Options:

  • initialAngleRadian: angle offset to begin from. This overrides the -Math.PI/2 default.
  • Parameters

    • outerRadius: number

      Outer radius. Maximum radius of a spike to origin

    • points: number = 5

      Number of points in the starburst. Defaults to five, which produces a typical star

    • OptionalinnerRadius: number

      Inner radius. A proportionally smaller inner radius makes for sharper spikes. If unspecified, 50% of the outer radius is used.

    • origin: Point = Points.Empty

      Origin, or { x:0, y:0 } by default.

    • Optionalopts: {
          initialAngleRadian?: number;
      }

      Options

      • Optional ReadonlyinitialAngleRadian?: number

    Returns readonly Point[]