The Polygon class represents a polygon, i.e. numerous vertices connected by lines.
Constructors
new(vertices : Array(Point))
Creates a new Polygon instance with an array of vertices.
Sourcenew(*vertices : Point)
Creates a new Polygon with variadic arguments.
SourceInstance methods
area
Returns the area of a polygon.
Sourceinclude?(other : Point)
Returns whether the given point lies on the polygon's perimeter.
Sourceperimeter
Returns the total perimeter of the polygon.
Sourcesegments
Returns an array of the line segments that make up the polygon.
The created array is in the form [Segment.new(p1, p2), Segment.new(p2, p3), ..., Segment.new(p(n-1), p(n)), Segment.new(p(n), p1)].
Sourcevertices
Returns all the vertices of the polygon.
Source