Tatooine
GnRP.h
Go to the documentation of this file.
1#ifndef TATOOINE_COLOR_SCALES_GNRP_H
2#define TATOOINE_COLOR_SCALES_GNRP_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/vec.h>
6
7#include <memory>
8//==============================================================================
10//==============================================================================
11template <floating_point Real>
12struct GnRP {
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.26666699999999999, 0.105882},
30 {0.066435999999999995, 0.394617, 0.17477899999999999},
31 {0.16885800000000001, 0.52456700000000001, 0.25767000000000001},
32 {0.32387500000000002, 0.657439, 0.36101499999999997},
33 {0.50488299999999997, 0.77231799999999995, 0.50634400000000002},
34 {0.67843100000000001, 0.87012699999999998, 0.65490199999999998},
35 {0.80392200000000003, 0.92179900000000004, 0.78039199999999997},
36 {0.89711600000000002, 0.95194199999999995, 0.88281399999999999},
37 {0.96739699999999995, 0.96593600000000002, 0.96747399999999995},
38 {0.92802799999999996, 0.87981500000000001, 0.93056499999999998},
39 {0.86605200000000004, 0.78077700000000005, 0.88289099999999998},
40 {0.77500999999999998, 0.66512899999999997, 0.821376},
41 {0.67566300000000001, 0.53702399999999995, 0.73702400000000001},
42 {0.57847000000000004, 0.39615499999999998, 0.64598199999999995},
43 {0.49234899999999998, 0.223914, 0.54755900000000002},
44 {0.37554799999999999, 0.096886, 0.42329899999999998},
45 {0.25097999999999998, 0, 0.29411799999999999}}} {}
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//==============================================================================
62GnRP()->GnRP<real_number>;
63//==============================================================================
64} // namespace tatooine::color_scales
65//==============================================================================
66#endif
67
Definition: BrBG.h:9
Definition: GnRP.h:12
Real real_type
Definition: GnRP.h:13
auto data_container() const -> color_type const *
Definition: GnRP.h:23
auto data() -> color_type *
Definition: GnRP.h:24
auto data_container() -> color_type *
Definition: GnRP.h:22
auto data() const -> color_type const *
Definition: GnRP.h:25
static constexpr std::size_t num_samples()
Definition: GnRP.h:16
auto operator()(real_type const t) const
Definition: GnRP.h:59
auto sample(real_type t) const
Definition: GnRP.h:47
GnRP()
Definition: GnRP.h:27
std::unique_ptr< color_type[]> m_data
Definition: GnRP.h:19
Definition: vec.h:12