Tatooine
BuRD.h
Go to the documentation of this file.
1#ifndef TATOOINE_COLOR_SCALES_BURD_H
2#define TATOOINE_COLOR_SCALES_BURD_H
3//==============================================================================
4#include <tatooine/concepts.h>
5#include <tatooine/vec.h>
6
7#include <memory>
8//==============================================================================
10//==============================================================================
11template <floating_point Real>
12struct BuRD {
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.019608, 0.18823500000000001, 0.38039200000000001},
30 {0.088503999999999999, 0.32110699999999998, 0.56493700000000002},
31 {0.16339899999999999, 0.44498300000000002, 0.69750100000000004},
32 {0.247059, 0.55570900000000001, 0.75409499999999996},
33 {0.420684, 0.67643200000000003, 0.818685},
34 {0.60645899999999997, 0.78977299999999995, 0.88027699999999998},
35 {0.76147600000000004, 0.86851199999999995, 0.92456700000000003},
36 {0.87804700000000002, 0.92572100000000002, 0.95194199999999995},
37 {0.96908899999999998, 0.96647400000000006, 0.96493700000000004},
38 {0.98385199999999995, 0.89757799999999999, 0.84682800000000003},
39 {0.98246800000000001, 0.80069199999999996, 0.70611299999999999},
40 {0.96032300000000004, 0.66781999999999997, 0.53633200000000003},
41 {0.89457900000000001, 0.50380599999999998, 0.39976899999999999},
42 {0.81706999999999996, 0.33217999999999998, 0.28104600000000002},
43 {0.72848900000000005, 0.15501699999999999, 0.19738600000000001},
44 {0.576932, 0.055363000000000002, 0.14924999999999999},
45 {0.403922, 0, 0.121569}}} {}
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//==============================================================================
62BuRD()->BuRD<real_number>;
63//==============================================================================
64} // namespace tatooine::color_scales
65//==============================================================================
66#endif
67
Definition: BrBG.h:9
Definition: BuRD.h:12
auto sample(real_type t) const
Definition: BuRD.h:47
static constexpr std::size_t num_samples()
Definition: BuRD.h:16
auto data() -> color_type *
Definition: BuRD.h:24
auto data_container() const -> color_type const *
Definition: BuRD.h:23
auto operator()(real_type const t) const
Definition: BuRD.h:59
auto data_container() -> color_type *
Definition: BuRD.h:22
auto data() const -> color_type const *
Definition: BuRD.h:25
Real real_type
Definition: BuRD.h:13
BuRD()
Definition: BuRD.h:27
std::unique_ptr< color_type[]> m_data
Definition: BuRD.h:19
Definition: vec.h:12