Skip to content

jitx/shapes/Polygon

Package name: jitx/shapes/Polygon

Summary

Polygon

Polygon

Functions

Function Description
circle-points Create a polygon consisting of points along an arc of a circle.
outline Create a line which traces the outline of the given polygon.
Polygon Create a polygon from a sequence of points and/or other nested sequences of points.

Definitions

Polygon

Polygon

public defstruct Polygon <: Shape & HasMetaUtils :
    points: Tuple<Point>

  • points: Tuple<Point> - Vertices of this polygon in counter-clockwise order.

A polygon specified by its vertices in counter-clockwise order.

Must be non-degenerate (have at least 3 vertices) and be non-self-intersecting. May be concave.

Functions

circle-points

Create a polygon consisting of points along an arc of a circle.

public defn circle-points (radius:Double, off:Double, tot:Double, num:Int) -> Polygon

  • radius: Double - The radius of the arc to sample points from.
  • off: Double - The starting angle of the arc to sample points from.
  • tot: Double - The counter-clockwise sweep angle of the arc to sample points from.
  • num: Int - The number of divisions to divide the arc into. The total number of points of the polygon will be num + 1.
  • Returns Polygon

Specified with a starting angle, sweep angle, and number of divisions.

outline

Create a line which traces the outline of the given polygon.

public defn outline (p:Polygon)

  • p: Polygon - The polygon to create the outline of.

The line has width 0.0.

Polygon

Create a polygon from a sequence of points and/or other nested sequences of points.

public defn Polygon (pts:Seqable<Point|Seqable>)

  • pts: Seqable<Point|Seqable> - The sequence of points and/or nested sequences of points to make the polygon from.

The sequence is "flattened" first to create the tuple of points used.

Related Packages

Forwarded by packages: jitx/shapes, jitx