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/core/api.h"
5#include "flint/graphics/shape.h"
6#include "flint/graphics/types/color.h"
7#include "flint/math/types.h"
8
9namespace Flint {
10
17 class CircleShape : public Shape {
18 public:
19 CircleShape() = default;
26 FLINT_API CircleShape(float radius, Color fill = {255, 255, 255, 255});
27
33 FLINT_API void setRadius(float radius);
34
40 void setOrigin(Vec2f newOrigin) {
41 m_origin = newOrigin;
42 }
43
49 void move(Vec2f delta) {
50 m_position.x += delta.x;
51 m_position.y += delta.y;
52 }
53
59 void setAngle(float newAngle) {
60 m_angle = newAngle;
61 }
62
64 [[nodiscard]] float getRadius() const {
65 return m_radius;
66 }
67
69 [[nodiscard]] const Vec2f &getOrigin() const {
70 return m_origin;
71 }
72
74 [[nodiscard]] float getAngle() const {
75 return m_angle;
76 }
77
82 [[nodiscard]] FloatRect getGlobalBounds() const override {
83 return FloatRect(m_position - m_origin, {2.0f * m_radius, 2.0f * m_radius});
84 }
85
89 FLINT_API void emit(RenderQueue &queue) const override;
90
91 private:
92 float m_radius = 0;
93 float m_angle = 0;
94 Vec2f m_origin{0.f, 0.f};
95 };
96
97}
A 2D circle rendered as a textured quad with a circle SDF shader.
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.
FLINT_API CircleShape(float radius, Color fill={255, 255, 255, 255})
Construct a circle with the given radius and fill color.
FloatRect getGlobalBounds() const override
Get the axis-aligned bounding box of the circle in world space.
FLINT_API void setRadius(float radius)
Set the circle radius.
float getRadius() const
Get the current radius in world-space units.
void move(Vec2f delta)
Translate the circle by delta.
void setAngle(float newAngle)
Set the rotation angle.
FLINT_API void emit(RenderQueue &queue) const override
Emit this drawable's rendering work for the current frame.
const Vec2f & getOrigin() const
Get the local origin pivot point.
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