Shape objects are display objects whose geometry encloses an area defined by a boundary.
Shapes can be created with the following methods:
| Object | Method |
|---|---|
| Rectangle | display.newRect() |
| Rounded Rectangle | display.newRoundedRect() |
| Circle | display.newCircle() |
| Polygon | display.newPolygon() |
| Line | display.newLine() |
| Mesh | display.newMesh() |
Most shapes have a object.path property. This property has limited child properties which let you manipulate specific aspects of the shape. These aspects can either be set explicitly or animated via a transition.
All rectangle objects have a RectPath. The width and height of this path can be manipulated, and you can achieve quadrilateral distortion by manipulating any of the four corner points of the path.
local rect = display.newRect( 160, 240, 150, 50 )
rect.path.x1 = -50
transition.to( rect.path, { time=2000, height=100, x1=0 } )
All rounded rectangle objects have a RoundedRectPath. The width and height of this path can be manipulated, along with the radius of the corners.
local roundedRect = display.newRoundedRect( 160, 240, 150, 50, 10 )
roundedRect.path.radius = 20
transition.to( roundedRect.path, { time=2000, width=100, height=100, radius=5 } )
All circle objects have a CirclePath for which the radius can be manipulated.
local circle = display.newCircle( 160, 240, 10 )
circle.path.radius = 50
transition.to( circle.path, { time=2000, radius=10 } )
All mesh objects have a path property that exposes methods to manipulate the mesh. See the display.newMesh() documentation for details.
All shapes have a fill and a stroke. The fill of a shape is the interior area of the geometry, while the stroke of a shape is its boundary.
Corona uses the concept of paint to specify how fills and strokes are drawn. In general, paints are specified via tables which contain the relevant data.
| Paint | Purpose |
|---|---|
| Paint | Fill/stroke an object with a solid color. |
| BitmapPaint | Fill/stroke an object with an image. |
| CompositePaint | Used for multi-texture fills/strokes. |
| GradientPaint | Used for linear gradient fills/strokes. |
| ImageSheetPaint | Fill/stroke an object with an image sheet frame. |