Skip to content
Permalink
Browse files

Added palette_converter_wrapper for any animation type that overload …

…value method and returning

converted value.
  • Loading branch information...
dev-0x7C6 committed Oct 1, 2018
1 parent 2428097 commit 5f46cca768d5e473f29bb730d9da9bfdf500c1c1
Showing with 12 additions and 4 deletions.
  1. +12 −4 src/animation/animation.hpp
@@ -16,7 +16,15 @@ concept bool animation_interface = requires(type object) {

// clang-format on

template <animation_interface animation_type, palette_category palette_category, auto elements>
template <animation_interface animation_type, palette_category category>
class palette_converter_wrapper : public animation_type { // eventualy operator. (aka dot) overload
public:
constexpr auto value() const noexcept {
return convert_palette<category>(animation_type::value());
}
};

template <animation_interface animation_type, palette_category category, auto elements>
class animator {
public:
constexpr animator(rgb *c)
@@ -25,17 +33,17 @@ class animator {
constexpr void rotate(int count = 1) {
for (int i = elements - 1; i > 0; i--)
m_colors[i] = m_colors[i - 1];
m_colors[0] = convert_palette<palette_category>(animation.value());
m_colors[0] = m_animation.value();
steps(count);
}

private:
constexpr void steps(int count) noexcept {
for (int i = 0; i < count; ++i)
animation.step();
m_animation.step();
}

private:
animation_type animation;
palette_converter_wrapper<animation_type, category> m_animation;
rgb *m_colors;
};

0 comments on commit 5f46cca

Please sign in to comment.
You can’t perform that action at this time.