Tatooine
OrPu.h
Go to the documentation of this file.
1#ifndef TATOOINE_COLOR_SCALES_ORPU_H
2#define TATOOINE_COLOR_SCALES_ORPU_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/vec.h>
6
7#include <memory>
8//==============================================================================
10//==============================================================================
11template <floating_point Real>
12struct OrPu {
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.17647099999999999, 0, 0.29411799999999999},
30 {0.27243400000000001, 0.095963000000000007, 0.444214},
31 {0.37339499999999998, 0.228912, 0.56932000000000005},
32 {0.48166100000000001, 0.41591699999999998, 0.65790099999999996},
33 {0.60192199999999996, 0.56293700000000002, 0.75048099999999995},
34 {0.71849300000000005, 0.695886, 0.83698600000000001},
35 {0.81199500000000002, 0.81153399999999998, 0.89850099999999999},
36 {0.894733, 0.89949999999999997, 0.94002300000000005},
37 {0.96916599999999997, 0.96685900000000002, 0.96362899999999996},
38 {0.98638999999999999, 0.91026499999999999, 0.80369100000000004},
39 {0.99500200000000005, 0.83537099999999997, 0.62437500000000001},
40 {0.99254100000000001, 0.73694700000000002, 0.42014600000000002},
41 {0.93194900000000003, 0.60945800000000006, 0.224221},
42 {0.85075000000000001, 0.48396800000000001, 0.069819000000000006},
43 {0.74002299999999999, 0.38062299999999999, 0.035371},
44 {0.61799300000000001, 0.29826999999999998, 0.026759000000000002},
45 {0.49803900000000001, 0.231373, 0.031372999999999998}}} {}
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//==============================================================================
62OrPu()->OrPu<real_number>;
63//==============================================================================
64} // namespace tatooine::color_scales
65//==============================================================================
66#endif
67
Definition: BrBG.h:9
Definition: OrPu.h:12
auto data() const -> color_type const *
Definition: OrPu.h:25
auto data() -> color_type *
Definition: OrPu.h:24
auto sample(real_type t) const
Definition: OrPu.h:47
OrPu()
Definition: OrPu.h:27
auto operator()(real_type const t) const
Definition: OrPu.h:59
std::unique_ptr< color_type[]> m_data
Definition: OrPu.h:19
Real real_type
Definition: OrPu.h:13
auto data_container() const -> color_type const *
Definition: OrPu.h:23
auto data_container() -> color_type *
Definition: OrPu.h:22
static constexpr std::size_t num_samples()
Definition: OrPu.h:16
Definition: vec.h:12