From 26293db40f8ac62f3971e0e9dbbc0bf3439e61c0 Mon Sep 17 00:00:00 2001 From: Vasile Vilvoiu Date: Tue, 29 Dec 2020 19:33:03 +0200 Subject: Initial commit --- src/color-map.hpp | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/color-map.hpp (limited to 'src/color-map.hpp') diff --git a/src/color-map.hpp b/src/color-map.hpp new file mode 100644 index 0000000..2878652 --- /dev/null +++ b/src/color-map.hpp @@ -0,0 +1,80 @@ +/* + * 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 \ No newline at end of file -- cgit v1.2.3