class

Geode::Polygon

Inherits Reference < Object

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.

Source
new(*vertices : Point)

Creates a new Polygon with variadic arguments.

Source

Instance methods

area

Returns the area of a polygon.

Source
include?(other : Point)

Returns whether the given point lies on the polygon's perimeter.

Source
perimeter

Returns the total perimeter of the polygon.

Source
segments

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)].

Source
vertices

Returns all the vertices of the polygon.

Source