Type Function Library display.* Return value ShapeObject Revision Release 2024.3703 Keywords rectangle, vector object See also Shapes — Paths, Fills, Strokes (guide) Display Objects (guide)
Creates a rectangle object. The local origin is at the center of the rectangle and the anchor point is initialized to this local origin.
display.newRect( [parent,] x, y, width, height )
GroupObject. An optional display group in which to insert the rectangle.
Number. The x and y coordinates for the center of the rectangle.
Number. Width and height of the rectangle.
(Inherits properties from ShapeObject)
Shape objects have a path
property that exposes properties of the path. The first corner is at the top-left and they go around in counter-clockwise order.
Number. The top-left corner. By default, (0,0)
.
Number. The bottom-left corner. By default, (0,0)
.
Number. The bottom-right corner. By default, (0,0)
.
Number. The top-right corner. By default, (0,0)
.
local myRectangle = display.newRect( 0, 0, 150, 50 ) myRectangle.strokeWidth = 3 myRectangle:setFillColor( 0.5 ) myRectangle:setStrokeColor( 1, 0, 0 )