#include "app.hh" #include "input.hh" #include #include #include namespace pg { namespace { class Gradient final : public App, public Input::Data { public: static inline TypeInfo kType = TypeInfo::Create("Input_Gradient"); Gradient() noexcept : Data("gradient") { } void Update() noexcept override { const auto id = std::to_string(index())+" Input_Gradient | "+ std::to_string(reinterpret_cast(this)); if (ImGui::Begin(id.c_str())) { ImGui::DragInt("w", &w_, 1, 1, 1024); ImGui::DragInt("h", &h_, 1, 1, 1024); ImGui::DragInt("dur", &dur_, 1, 1, 1024); } ImGui::End(); } Frame Fetch(size_t n) noexcept override { const auto w = static_cast(w_); const auto h = static_cast(h_); buf_.resize(w*h*4); const auto f = static_cast(n)/static_cast(dur_); std::memset(buf_.data(), static_cast(f*UINT8_MAX), buf_.size()); return Frame {.w = w, .h = h, .rgba = buf_.data()}; } size_t frames() noexcept override { return static_cast(dur_); } private: int w_ = 100, h_ = 100; int dur_ = 100; std::vector buf_; }; } } // namespace pg