Tatooine
GnYIRd.h
Go to the documentation of this file.
1#ifndef TATOOINE_COLOR_SCALES_GNYIRD_H
2#define TATOOINE_COLOR_SCALES_GNYIRD_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/vec.h>
6
7#include <memory>
8//==============================================================================
10//==============================================================================
11template <floating_point Real>
12struct GnYIRd {
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, 0.40784300000000001, 0.21568599999999999},
30 {0.063975000000000004, 0.52595199999999998, 0.27720099999999998},
31 {0.17793200000000001, 0.63306399999999996, 0.33271800000000001},
32 {0.36493700000000001, 0.72410600000000003, 0.379469},
33 {0.52795099999999995, 0.79715499999999995, 0.40222999999999998},
34 {0.67843100000000001, 0.86282199999999998, 0.43344899999999997},
35 {0.80392200000000003, 0.91695499999999996, 0.51464799999999999},
36 {0.90941899999999998, 0.96186099999999997, 0.62506700000000004},
37 {0.99992300000000001, 0.99761599999999995, 0.74502100000000004},
38 {0.99746299999999999, 0.92133799999999999, 0.61707000000000001},
39 {0.99500200000000005, 0.82460599999999995, 0.49988500000000002},
40 {0.99254100000000001, 0.70157599999999998, 0.39654},
41 {0.973472, 0.54740500000000003, 0.318108},
42 {0.93902300000000005, 0.38992700000000002, 0.24552099999999999},
43 {0.86766600000000005, 0.23983099999999999, 0.176624},
44 {0.76239900000000005, 0.11072700000000001, 0.15132599999999999},
45 {0.64705900000000005, 0, 0.14902000000000001}
46 }} {}
47 //----------------------------------------------------------------------------
48 auto sample(real_type t) const {
49 if (t <= 0) {
50 return m_data[0];
51 }
52 if (t >= 1) {
53 return m_data[(num_samples() - 1)];
54 }
55 t *= num_samples() - 1;
56 auto const i = static_cast<std::size_t>(std::floor(t));
57 t = t - i;
58 return m_data[i] * (1 - t) + m_data[i + 1] * t;
59 }
60 auto operator()(real_type const t) const { return sample(t); }
61};
62//==============================================================================
63GnYIRd()->GnYIRd<real_number>;
64//==============================================================================
65} // namespace tatooine::color_scales
66//==============================================================================
67#endif
68
Definition: BrBG.h:9
Definition: GnYIRd.h:12
auto sample(real_type t) const
Definition: GnYIRd.h:48
std::unique_ptr< color_type[]> m_data
Definition: GnYIRd.h:19
auto operator()(real_type const t) const
Definition: GnYIRd.h:60
static constexpr std::size_t num_samples()
Definition: GnYIRd.h:16
auto data_container() const -> color_type const *
Definition: GnYIRd.h:23
Real real_type
Definition: GnYIRd.h:13
auto data() const -> color_type const *
Definition: GnYIRd.h:25
GnYIRd()
Definition: GnYIRd.h:27
auto data_container() -> color_type *
Definition: GnYIRd.h:22
auto data() -> color_type *
Definition: GnYIRd.h:24
Definition: vec.h:12