/* * Copyright (c) 2020-2021 Vasile Vilvoiu * * specgram is free software; you can redistribute it and/or modify * it under the terms of the MIT license. See LICENSE for details. */ #ifndef _COLOR_MAP_HPP_ #define _COLOR_MAP_HPP_ #include "input-parser.hpp" #include #include #include #include enum class ColorMapType { /* MATLAB jet map */ kJet, /* bicolor maps */ kGray, kPurple, kBlue, kGreen, kOrange, kRed, /* custom; bg->color */ kCustom }; class ColorMap { protected: ColorMap() = default; public: ColorMap(const ColorMap&) = default; static std::unique_ptr FromType(ColorMapType type, const sf::Color& bg_color, const sf::Color& custom_color); virtual std::vector Map(const RealWindow& input) const = 0; std::vector Gradient(std::size_t width) const; }; class InterpolationColorMap : public ColorMap { private: const std::vector colors_; const std::vector values_; std::vector GetColor(double value) const; protected: InterpolationColorMap(const std::vector& colors, const std::vector& vals); public: InterpolationColorMap() = delete; std::vector Map(const std::vector& input) const override; }; class TwoColorMap : public InterpolationColorMap { public: TwoColorMap(const sf::Color& c1, const sf::Color& c2); }; class ThreeColorMap : public InterpolationColorMap { public: ThreeColorMap(const sf::Color& c1, const sf::Color& c2, const sf::Color& c3); }; class JetColorMap : public InterpolationColorMap { public: JetColorMap(); }; #endif