Tatooine
GBBr.h
Go to the documentation of this file.
1#ifndef TATOOINE_COLOR_SCALES_GBBR_H
2#define TATOOINE_COLOR_SCALES_GBBR_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/vec.h>
6
7#include <memory>
8//==============================================================================
10//==============================================================================
11template <floating_point Real>
12struct GBBr {
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.235294, 0.18823500000000001},
30 {0.0024610000000000001, 0.33863900000000002, 0.301423},
31 {0.055902, 0.44898100000000002, 0.41760900000000001},
32 {0.18385199999999999, 0.56955, 0.53817800000000005},
33 {0.35778500000000002, 0.70011500000000004, 0.66074600000000006},
34 {0.54017700000000002, 0.81953100000000001, 0.77624000000000004},
35 {0.71487900000000004, 0.89088800000000001, 0.86482099999999995},
36 {0.85113399999999995, 0.93456399999999995, 0.92264500000000005},
37 {0.96086099999999997, 0.959785, 0.95694000000000001},
38 {0.96332200000000001, 0.92779699999999998, 0.83391000000000004},
39 {0.93994599999999995, 0.86889700000000003, 0.68935000000000002},
40 {0.88335300000000005, 0.77539400000000003, 0.51710900000000004},
41 {0.80807399999999996, 0.62583599999999995, 0.32410600000000001},
42 {0.71764700000000003, 0.47635499999999997, 0.15493999999999999},
43 {0.59215700000000004, 0.35824699999999998, 0.068820000000000006},
44 {0.45859299999999997, 0.26435999999999998, 0.031142},
45 {0.32941199999999998, 0.18823500000000001, 0.019608}}} {}
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//==============================================================================
62GBBr()->GBBr<real_number>;
63//==============================================================================
64} // namespace tatooine::color_scales
65//==============================================================================
66#endif
67
Definition: BrBG.h:9
Definition: GBBr.h:12
std::unique_ptr< color_type[]> m_data
Definition: GBBr.h:19
auto data() -> color_type *
Definition: GBBr.h:24
Real real_type
Definition: GBBr.h:13
static constexpr std::size_t num_samples()
Definition: GBBr.h:16
auto data() const -> color_type const *
Definition: GBBr.h:25
auto data_container() -> color_type *
Definition: GBBr.h:22
GBBr()
Definition: GBBr.h:27
auto sample(real_type t) const
Definition: GBBr.h:47
auto operator()(real_type const t) const
Definition: GBBr.h:59
auto data_container() const -> color_type const *
Definition: GBBr.h:23
Definition: vec.h:12