#pragma once #include #include #include #include #include "core/image.hpp" #include "core/params.hpp" #include "core/rng.hpp" namespace effector { class EffectError : public std::runtime_error { public: using std::runtime_error::runtime_error; }; // Base class for every effect. Canvas size and the random source are common to // all of them; params() covers only the effect-specific knobs. class Effect { public: virtual ~Effect() = default; virtual std::string name() const = 0; virtual std::string title() const = 0; virtual std::string description() const = 0; virtual const std::vector& params() const = 0; // Whether the effect builds its image out of the loaded source images. // Effects that only transform what they are handed (blur) say no, and a // chain that starts with one of them needs no sources at all. virtual bool needsSources() const { return true; } virtual Image render(const std::vector& sources, int width, int height, Rng& rng, const ParamValues& values) const = 0; ParamValues defaults() const; }; using EffectPtr = std::shared_ptr; } // namespace effector