Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::RectangleShape Class Reference

A 2D axis-aligned rectangle rendered as a textured quad. More...

#include <flint/graphics/rectangle-shape.h>

+ Inheritance diagram for Flint::RectangleShape:
+ Collaboration diagram for Flint::RectangleShape:

Public Member Functions

FLINT_API RectangleShape (Vec2f size, Color fill={255, 255, 255, 255})
 Construct a rectangle with the given dimensions and fill color.
 
FLINT_API void setSize (Vec2f newSize)
 Set the rectangle dimensions.
 
void setOrigin (Vec2f newOrigin)
 Set the local pivot point used for rotation and positioning.
 
void setScale (Vec2f newScale)
 Apply a per-axis scale factor.
 
void setRotation (float newRotation)
 Set the rotation angle.
 
Vec2f getSize () const
 Get the current dimensions in world-space units.
 
const Vec2f & getOrigin () const
 Get the current local origin pivot point.
 
const Vec2f & getScale () const
 Get the current scale factors.
 
float getRotation () const
 Get the current rotation angle in radians.
 
FloatRect getGlobalBounds () const override
 Get the axis-aligned bounding box of the rectangle in world space.
 
FLINT_API void emit (RenderQueue &queue) const override
 Emit this drawable's rendering work for the current frame.
 
- Public Member Functions inherited from Flint::Shape
virtual void setPosition (Vec2f newPosition)
 Set the world-space position of the shape.
 
virtual void setFillColor (Color color)
 Set the fill (interior) color.
 
virtual void setOutlineColor (Color color)
 Set the outline (stroke) color.
 
virtual void setOutlineThickness (float thickness)
 Set the outline stroke thickness in pixels.
 
virtual Vec2f getPosition () const
 Return the current world-space position.
 
virtual Color getFillColor () const
 Return the current fill color.
 
virtual Color getOutlineColor () const
 Return the current outline color.
 
virtual float getOutlineThickness () const
 Return the current outline thickness in pixels.
 
- Public Member Functions inherited from Flint::Drawable
void setGPUTexture (GPUTexture *texture)
 Associate a texture with this drawable.
 
GPUTexture * getGPUTexture () const
 Get the associated GPU texture.
 

Additional Inherited Members

- Protected Attributes inherited from Flint::Shape
Vec2f m_position {0, 0}
 
Color m_fillColor {255, 255, 255, 255}
 
Color m_outlineColor {0, 0, 0, 0}
 
float m_outlineThickness {0.f}
 
- Protected Attributes inherited from Flint::Drawable
GPUTexture * m_gpuTexture = nullptr
 Non-owning reference to the GPU texture asset.
 

Detailed Description

A 2D axis-aligned rectangle rendered as a textured quad.

Inherits position, fill/outline color, and outline thickness from Shape. Supports independent scaling, rotation, and origin pivot offset.

Definition at line 21 of file rectangle-shape.h.

Constructor & Destructor Documentation

◆ RectangleShape()

FLINT_API Flint::RectangleShape::RectangleShape ( Vec2f size,
Color fill = {255, 255, 255, 255} )

Construct a rectangle with the given dimensions and fill color.

Parameters
sizeWorld-space width (x) and height (y).
fillInitial fill color (default: opaque white).

Member Function Documentation

◆ emit()

FLINT_API void Flint::RectangleShape::emit ( RenderQueue & queue) const
overridevirtual

Emit this drawable's rendering work for the current frame.

Called once after submitted drawables have been sorted by DrawLayer. Implementations must enqueue work through queue rather than issuing immediate GPU commands.

Parameters
queueQueue receiving this drawable's rendering work.

Implements Flint::Drawable.

◆ getGlobalBounds()

FloatRect Flint::RectangleShape::getGlobalBounds ( ) const
inlinenodiscardoverridevirtual

Get the axis-aligned bounding box of the rectangle in world space.

Returns
FloatRect World-space AABB.

Reimplemented from Flint::Shape.

Definition at line 91 of file rectangle-shape.h.

◆ getOrigin()

const Vec2f & Flint::RectangleShape::getOrigin ( ) const
inlinenodiscard

Get the current local origin pivot point.

Definition at line 73 of file rectangle-shape.h.

◆ getRotation()

float Flint::RectangleShape::getRotation ( ) const
inlinenodiscard

Get the current rotation angle in radians.

Definition at line 83 of file rectangle-shape.h.

◆ getScale()

const Vec2f & Flint::RectangleShape::getScale ( ) const
inlinenodiscard

Get the current scale factors.

Definition at line 78 of file rectangle-shape.h.

◆ getSize()

Vec2f Flint::RectangleShape::getSize ( ) const
inlinenodiscard

Get the current dimensions in world-space units.

Definition at line 68 of file rectangle-shape.h.

◆ setOrigin()

void Flint::RectangleShape::setOrigin ( Vec2f newOrigin)
inline

Set the local pivot point used for rotation and positioning.

Parameters
newOriginPivot offset in local object space.

Definition at line 45 of file rectangle-shape.h.

◆ setRotation()

void Flint::RectangleShape::setRotation ( float newRotation)
inline

Set the rotation angle.

Parameters
newRotationAngle in radians (clockwise).

Definition at line 63 of file rectangle-shape.h.

◆ setScale()

void Flint::RectangleShape::setScale ( Vec2f newScale)
inline

Apply a per-axis scale factor.

Parameters
newScaleScale factors (1.0, 1.0 = original size).

Definition at line 54 of file rectangle-shape.h.

◆ setSize()

FLINT_API void Flint::RectangleShape::setSize ( Vec2f newSize)

Set the rectangle dimensions.

Parameters
newSizeNew width and height in world-space units.

The documentation for this class was generated from the following file: