Skip to content

class SF::RectangleShape
inherits SF::Shape #

Specialized shape representing a rectangle

This class inherits all the functions of SF::Transformable (position, rotation, scale, bounds, ...) as well as the functions of SF::Shape (outline, color, texture, ...).

Usage example:

rectangle =
rectangle.size = SF.vector2f(100, 50)
rectangle.outline_color = SF::Color::Red
rectangle.outline_thickness = 5
rectangle.position = {10, 20}
# [...]
window.draw rectangle

See also: SF::Shape, SF::CircleShape, SF::ConvexShape


.new(size : Vector2 | Tuple =, 0))#

Default constructor

  • size - Size of the rectangle
View source


#dup : RectangleShape#

Returns a shallow copy of this object.

This allocates a new object and copies the contents of self into it.

View source


Virtual destructor

View source

#get_point(index : Int) : Vector2f#

Get a point of the rectangle

The returned point is in local coordinates, that is, the shape's transforms (position, rotation, scale) are not taken into account. The result is undefined if index is out of the valid range.

  • index - Index of the point to get, in range 0..3

Returns: index-th point of the shape

View source

#point_count : Int32#

Get the number of points defining the shape

Returns: Number of points of the shape. For rectangle shapes, this number is always 4.

View source

#size : Vector2f#

Get the size of the rectangle

Returns: Size of the rectangle

See also: size=

View source

#size=(size : Vector2 | Tuple)#

Set the size of the rectangle

  • size - New size of the rectangle

See also: size

View source