Tatooine
GYPi.h
Go to the documentation of this file.
1#ifndef TATOOINE_COLOR_SCALES_GYPI_H
2#define TATOOINE_COLOR_SCALES_GYPI_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/vec.h>
6
7#include <memory>
8//==============================================================================
10//==============================================================================
11template <floating_point Real>
12struct GYPi {
13 using real_type = Real;
16 static constexpr std::size_t num_samples() { return 17; }
17 //==============================================================================
18 private:
19 std::unique_ptr<color_type[]> m_data;
20
21 public:
22 auto data_container() -> color_type* { return m_data; }
23 auto data_container() const -> color_type const* { return m_data; }
24 auto data() -> color_type* { return m_data.get(); }
25 auto data() const -> color_type const* { return m_data.get(); }
26 //==============================================================================
28 : m_data{new color_type[]{
29 {0.15294099999999999, 0.39215699999999998, 0.098039000000000001},
30 {0.246444, 0.50534400000000002, 0.117724},
31 {0.35194199999999998, 0.614533, 0.16139899999999999},
32 {0.47497099999999998, 0.71787800000000002, 0.24013799999999999},
33 {0.61199499999999996, 0.811226, 0.392849},
34 {0.74632799999999999, 0.89311799999999997, 0.56532099999999996},
35 {0.85951599999999995, 0.94233, 0.74740499999999999},
36 {0.92810499999999996, 0.96386000000000005, 0.87566299999999997},
37 {0.96908899999999998, 0.96685900000000002, 0.96801199999999998},
38 {0.98385199999999995, 0.91026499999999999, 0.94832799999999995},
39 {0.97923899999999997, 0.83321800000000001, 0.91464800000000002},
40 {0.949712, 0.72987299999999999, 0.86297599999999997},
41 {0.90565200000000001, 0.58292999999999995, 0.76355200000000001},
42 {0.85521000000000003, 0.41007300000000002, 0.65221099999999999},
43 {0.79369500000000004, 0.183699, 0.53164199999999995},
44 {0.68373700000000004, 0.063898999999999997, 0.420761},
45 {0.556863, 0.0039220000000000001, 0.32156899999999999}}} {}
46 //----------------------------------------------------------------------------
47 auto sample(real_type t) const {
48 if (t <= 0) {
49 return m_data[0];
50 }
51 if (t >= 1) {
52 return m_data[(num_samples() - 1)];
53 }
54 t *= num_samples() - 1;
55 auto const i = static_cast<std::size_t>(std::floor(t));
56 t = t - i;
57 return m_data[i] * (1 - t) + m_data[i + 1] * t;
58 }
59 auto operator()(real_type const t) const { return sample(t); }
60};
61//==============================================================================
62GYPi()->GYPi<real_number>;
63//==============================================================================
64} // namespace tatooine::color_scales
65//==============================================================================
66#endif
67
Definition: BrBG.h:9
Definition: GYPi.h:12
auto data_container() -> color_type *
Definition: GYPi.h:22
auto operator()(real_type const t) const
Definition: GYPi.h:59
auto data_container() const -> color_type const *
Definition: GYPi.h:23
Real real_type
Definition: GYPi.h:13
GYPi()
Definition: GYPi.h:27
static constexpr std::size_t num_samples()
Definition: GYPi.h:16
std::unique_ptr< color_type[]> m_data
Definition: GYPi.h:19
auto sample(real_type t) const
Definition: GYPi.h:47
auto data() -> color_type *
Definition: GYPi.h:24
auto data() const -> color_type const *
Definition: GYPi.h:25
Definition: vec.h:12