1// Aseprite
2// Copyright (C) 2019 Igara Studio S.A.
3// Copyright (C) 2017-2018 David Capello
4//
5// This program is distributed under the terms of
6// the End-User License Agreement for Aseprite.
7
8#ifndef FILTERS_HUE_SATURATION_FILTER_H_INCLUDED
9#define FILTERS_HUE_SATURATION_FILTER_H_INCLUDED
10#pragma once
11
12#include "doc/color.h"
13#include "filters/filter.h"
14#include "filters/target.h"
15
16namespace filters {
17
18 class HueSaturationFilter : public FilterWithPalette {
19 public:
20 enum class Mode {
21 HSV_MUL, HSL_MUL,
22 HSV_ADD, HSL_ADD,
23 };
24
25 HueSaturationFilter();
26
27 void setMode(Mode mode);
28 void setHue(double h);
29 void setSaturation(double s);
30 void setLightness(double v);
31 void setAlpha(double a);
32
33 // Filter implementation
34 const char* getName() override;
35 void applyToRgba(FilterManager* filterMgr) override;
36 void applyToGrayscale(FilterManager* filterMgr) override;
37 void applyToIndexed(FilterManager* filterMgr) override;
38
39 private:
40 void onApplyToPalette(FilterManager* filterMgr,
41 const doc::PalettePicks& picks) override;
42
43 template<class T,
44 double (T::*get_lightness)() const,
45 void (T::*set_lightness)(double)>
46 void applyFilterToRgbT(const Target target, doc::color_t& color, bool multiply);
47 void applyFilterToRgb(const Target target, doc::color_t& color);
48
49 Mode m_mode;
50 double m_h, m_s, m_l, m_a;
51 };
52
53} // namespace filters
54
55#endif
56