Skip to content

Commit 2866935

Browse files
authored
Merge pull request #207 from NOOBDY/animation-aa
added useAA for Util::Animation
2 parents 3122a5d + 617aa93 commit 2866935

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

include/Util/Animation.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Animation : public Core::Drawable {
3737
*/
3838
Animation(const std::vector<std::string> &paths, bool play,
3939
std::size_t interval, bool looping = true,
40-
std::size_t cooldown = 100);
40+
std::size_t cooldown = 100, bool useAA = true);
4141

4242
/**
4343
* @brief Get the interval between frames.
@@ -99,6 +99,20 @@ class Animation : public Core::Drawable {
9999
*/
100100
void SetCooldown(int cooldown) { m_Cooldown = cooldown; }
101101

102+
/**
103+
* @brief Sets whether anti-aliasing (AA) should be enabled or disabled.
104+
*
105+
* @param useAA A boolean value indicating whether anti-aliasing should be
106+
* enabled (true) or disabled (false).
107+
*
108+
* @note This function only sets the internal flag for anti-aliasing and
109+
* does not directly affect rendering. The actual effect of anti-aliasing
110+
* depends on the rendering pipeline and the graphics hardware capabilities.
111+
*
112+
* @sa https://en.wikipedia.org/wiki/Spatial_anti-aliasing
113+
*/
114+
void UseAntiAliasing(bool useAA);
115+
102116
/**
103117
* @brief Set the current frame of the animation.
104118
* @param index Index of the frame to set as current.

src/Util/Animation.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,21 @@
44

55
namespace Util {
66
Animation::Animation(const std::vector<std::string> &paths, bool play,
7-
std::size_t interval, bool looping, std::size_t cooldown)
7+
std::size_t interval, bool looping, std::size_t cooldown,
8+
bool useAA)
89
: m_State(play ? State::PLAY : State::PAUSE),
910
m_Interval(interval),
1011
m_Looping(looping),
1112
m_Cooldown(cooldown) {
1213
m_Frames.reserve(paths.size());
1314
for (const auto &path : paths) {
14-
m_Frames.push_back(std::make_shared<Util::Image>(path));
15+
m_Frames.push_back(std::make_shared<Util::Image>(path, useAA));
16+
}
17+
}
18+
19+
void Animation::UseAntiAliasing(bool useAA) {
20+
for (const auto &frame : m_Frames) {
21+
frame->UseAntiAliasing(useAA);
1522
}
1623
}
1724

0 commit comments

Comments
 (0)