Module shape

Defines a shape for use in a ShapeMatcher.

A shape must be built from line segments and does not support curves.

Shape extends BoundObject

Properties

name (readonly) The name of the shape.
segments (readonly) The segments that make up the shape.

Class Methods

SpriteAnimation:new (name, ...) Create a new Shape from a name and segment definitions.


Properties

Properties. Significant fields on an instance.
name
(readonly) The name of the shape.
segments
(readonly) The segments that make up the shape. This is a sequence of tables.

A segment is a table like {length = 1, angle = 90}

Class Methods

Class Methods. Must be called on Class, with a capital leading character. e.g. Class:method("foo")
SpriteAnimation:new (name, ...)
Create a new Shape from a name and segment definitions.

The shape definition always omits the initial segment.

Parameters:

  • name string A name for the shape.
  • ... table A sequence of tables with keys length and angle. length is the length of the segment relative to the first segment. angle is the angle in degrees at which to extend the segment from the one before it based on the convex winding direction.

Returns:

    Shape

Usage:

        local square = Shape:new("Square",
                                 { length = 1, angle = 90},
                                 { length = 1, angle = 90},
                                 { length = 1, angle = 90})
generated by LDoc 1.3.12