Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
circle-shape.h
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2025-2026 Manuel Osorio
3#pragma once
4#include "flint/graphics/shape.h"
5#include "flint/graphics/types/color.h"
6#include "flint/math/types.h"
7
8namespace Flint {
9
16 class CircleShape : public Shape {
17 public:
18 CircleShape() = default;
25 CircleShape(float radius, Color fill = {255, 255, 255, 255});
26
32 void setRadius(float radius);
33
39 void setOrigin(Vec2f newOrigin) {
40 m_origin = newOrigin;
41 }
42
48 void move(Vec2f delta) {
49 m_position.x += delta.x;
50 m_position.y += delta.y;
51 }
52
58 void setAngle(float newAngle) {
59 m_angle = newAngle;
60 }
61
63 [[nodiscard]] float getRadius() const {
64 return m_radius;
65 }
66
68 [[nodiscard]] const Vec2f &getOrigin() const {
69 return m_origin;
70 }
71
73 [[nodiscard]] float getAngle() const {
74 return m_angle;
75 }
76
81 [[nodiscard]] FloatRect getGlobalBounds() const override {
82 return FloatRect(m_position - m_origin, {2.0f * m_radius, 2.0f * m_radius});
83 }
84
88 void emit(RenderQueue &queue) const override;
89
90 private:
91 float m_radius = 0;
92 float m_angle = 0;
93 Vec2f m_origin{0.f, 0.f};
94 };
95
96}
float getAngle() const
Return the current rotation angle in radians.
void setOrigin(Vec2f newOrigin)
Set the local pivot point used as the rotation and positioning origin.
FloatRect getGlobalBounds() const override
Get the axis-aligned bounding box of the circle in world space.
void emit(RenderQueue &queue) const override
Emit this drawable's rendering work for the current frame.
float getRadius() const
Get the current radius in world-space units.
void move(Vec2f delta)
Translate the circle by delta.
CircleShape(float radius, Color fill={255, 255, 255, 255})
Construct a circle with the given radius and fill color.
void setRadius(float radius)
Set the circle radius.
void setAngle(float newAngle)
Set the rotation angle.
const Vec2f & getOrigin() const
Get the local origin pivot point.
A 2D circle rendered as a textured quad with a circle SDF shader.
Batches drawables into sorted geometry, primitive, and custom execution passes for GPURenderer.
Abstract base class for 2-D geometric shapes.
Definition shape.h:20
RGBA color with 8-bit unsigned components.
Definition color.h:13