Polygons
Arc
Arc([arc, radius, orbit], anchor?=, cap?, pos?, angle?) -> shape
Returns an arc Polygon. An arc is curved line that follows the edge of a circle. This can be used by functions like PolygonCollider or PolygonSprite.
arc(Number): The angular width of the arc in radians. For example,0.25revwould make an arc that covered one quarter of a circle.radius(Number): The half-width of the line that you would like to draw.orbit(Number): The distance from the line to the focal point of the arc. A smaller number makes a tighter arc.cap(Boolean): Whether the ends of the arc are rounded.anchor(Number): If set to1(the default), the center of the arc's line will be placed at the origin. If set to0, the focal point of the arc will be placed at the origin.pos(Vector): offsets the arc from the origin by this amount.angle(Number): rotates the arc by this angle, specified in radians.
Capsule
Capsule([extent, radius], pos?=, angle?) -> shape
Returns a capsule Polygon. A capsule is a single horizontal line segment with rounded ends.
pos(Vector): Offsets the position of the capsule by the given vector.angle(Number): Rotates the capsule by the given angle in radians.
A capsule has two focal points, each in the center of its two rounded ends.
extent(Number): Defines the distance from the center of the capsule to the two focal points. In other words, defines the half-width of the capsule.radius(Number): Defines the distance from a focal point to the edge of the capsule. In other words, defines the half-height of the capsule.
Circle
Circle([radius], pos?=) -> shape
Returns a circle Polygon.
radiuscontrols the width of the circle. It is the distance from the center of the circle to the edge of the circle.possets the position of the circle.
Equilateral
Equilateral(numPoints, [radius], pos?=, angle?) -> shape
Returns an equilateral Polygon. An equilateral polygon is a regular polygon with all sides and angles equal.
numPointsis the number of points in the polygon. If it is less than 3, the polygon will be a circle.radiuscontrols the width of the polygon. It is the distance from the center of the polygon to the edge of the polygon.posandanglesets the position and angle of the polygon respectively.
Line
Line(points, [radius], cap?=, headCap?, tailCap?, headTilt?, tailTilt?) -> shape
Returns a line Polygon.
pointsis an array of points that form the line. Each point will be connected to the next point in the array.radiuscontrols the radius of the line. If it is a single number, the line will have a constant radius. If it is an array of two numbers, the line's radius will be tapered from the first number to the second number. If there are more than two numbers provided, only the first and last number will be used.- If
capis true, then both of the line's ends will be rounded. - If
headCapis true, then the first point in the line will be rounded. - If
tailCapis true, then the last point in the line will be rounded. headTiltandtailTiltcontrol the tilt of the line's ends. A value of 0 will make the line's ends perpendicular to the line, whereas a non-zero value will tilt the line's ends by that amount.
Polygon
Polygon(points, border?=) -> shape
Returns a polygon shape.
points(Array): an array of points that form the perimeter of the polygon. Each point will be connected to the next point in the array, and then the last point will be connected back onto the first point.
Rectangle
Rectangle(pos?=, angle?, width, height) -> shape
Returns a rectangle Polygon.
pos(Vector): Offsets the position of this rectangle by the given vector.angle(Number): Rotates the rectangle by the given angle in radians.width(Number): The width of the rectangle.height(Number): The height of the rectangle.
Sector
Sector(arc, [radius], pos?=, angle?) -> shape
Returns a sector Polygon. A sector is a portion of a circle enclosed by two radii and an arc.
arcis the angular width of the sector in radians.radiuscontrols the size of the sector. It is the distance from the center of the sector's circle to the edge of the sector.posandanglesets the position and angle of the sector respectively.