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

Abstract base class for 2-D geometric shapes. More...

#include <flint/graphics/shape.h>

+ Inheritance diagram for Flint::Shape:
+ Collaboration diagram for Flint::Shape:

Public Member Functions

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.
 
virtual FloatRect getGlobalBounds () const
 Return the axis-aligned bounding rectangle in world space.
 
- Public Member Functions inherited from Flint::Drawable
virtual void emit (RenderQueue &queue) const =0
 Emit this drawable's rendering work for the current frame.
 
void setGPUTexture (GPUTexture *texture)
 Associate a texture with this drawable.
 
GPUTexture * getGPUTexture () const
 Get the associated GPU texture.
 

Protected Attributes

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

Abstract base class for 2-D geometric shapes.

Extends Drawable with position, fill color, outline color, and outline thickness. Concrete shapes (CircleShape, RectangleShape, etc.) implement the draw() overloads and override getGlobalBounds() to return their axis-aligned bounding rectangle in world space.

Definition at line 20 of file shape.h.

Member Function Documentation

◆ getFillColor()

virtual Color Flint::Shape::getFillColor ( ) const
inlinevirtual

Return the current fill color.

Definition at line 66 of file shape.h.

◆ getGlobalBounds()

virtual FloatRect Flint::Shape::getGlobalBounds ( ) const
inlinevirtual

Return the axis-aligned bounding rectangle in world space.

The base implementation returns a rect sized to the associated Texture (if any) at the current position. Subclasses should override this with geometry-specific bounds.

Returns
World-space AABB as a FloatRect.

Reimplemented in Flint::CircleShape, and Flint::RectangleShape.

Definition at line 89 of file shape.h.

◆ getOutlineColor()

virtual Color Flint::Shape::getOutlineColor ( ) const
inlinevirtual

Return the current outline color.

Definition at line 71 of file shape.h.

◆ getOutlineThickness()

virtual float Flint::Shape::getOutlineThickness ( ) const
inlinevirtual

Return the current outline thickness in pixels.

Definition at line 76 of file shape.h.

◆ getPosition()

virtual Vec2f Flint::Shape::getPosition ( ) const
inlinevirtual

Return the current world-space position.

Definition at line 61 of file shape.h.

◆ setFillColor()

virtual void Flint::Shape::setFillColor ( Color color)
inlinevirtual

Set the fill (interior) color.

Parameters
colorRGBA fill color.

Definition at line 38 of file shape.h.

◆ setOutlineColor()

virtual void Flint::Shape::setOutlineColor ( Color color)
inlinevirtual

Set the outline (stroke) color.

Parameters
colorRGBA outline color.

Definition at line 47 of file shape.h.

◆ setOutlineThickness()

virtual void Flint::Shape::setOutlineThickness ( float thickness)
inlinevirtual

Set the outline stroke thickness in pixels.

Parameters
thicknessThickness in pixels (0 = no outline).

Definition at line 56 of file shape.h.

◆ setPosition()

virtual void Flint::Shape::setPosition ( Vec2f newPosition)
inlinevirtual

Set the world-space position of the shape.

Parameters
newPositionNew position (top-left corner or center, depending on the shape).

Definition at line 29 of file shape.h.

Member Data Documentation

◆ m_fillColor

Color Flint::Shape::m_fillColor {255, 255, 255, 255}
protected

Definition at line 97 of file shape.h.

◆ m_outlineColor

Color Flint::Shape::m_outlineColor {0, 0, 0, 0}
protected

Definition at line 98 of file shape.h.

◆ m_outlineThickness

float Flint::Shape::m_outlineThickness {0.f}
protected

Definition at line 99 of file shape.h.

◆ m_position

Vec2f Flint::Shape::m_position {0, 0}
protected

Definition at line 96 of file shape.h.


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