1 #ifndef SIMPT_CELL_COLOR_HSV_H_
2 #define SIMPT_CELL_COLOR_HSV_H_
29 using hsv_t = std::tuple<double, double, double>;
34 const hsv_t black { 0.0 / 360.0, 0.0, 0.0 };
35 const hsv_t white {180.0 / 360.0, 0.0, 1.0 };
36 const hsv_t red { 0.0 / 360.0, 1.0, 1.0 };
37 const hsv_t lime {120.0 / 360.0, 1.0, 1.0 };
38 const hsv_t blue {240.0 / 360.0, 1.0, 1.0 };
39 const hsv_t yellow { 60.0 / 360.0, 1.0, 1.0 };
40 const hsv_t cyan {180.0 / 360.0, 1.0, 1.0 };
41 const hsv_t magenta {300.0 / 360.0, 1.0, 1.0 };
42 const hsv_t gray { 0.0 / 360.0, 0.0, 0.5 };
43 const hsv_t teal {180.0 / 360.0, 1.0, 0.5 };
44 const hsv_t navy {240.0 / 360.0, 1.0, 0.5 };
46 inline hsv_t interpolate(
double x, hsv_t t_a,
double x_a, hsv_t t_b,
double x_b)
49 assert(x_a <= x && x <= x_b);
51 const double s = (x - x_a) / (x_b - x_a);
52 return std::make_tuple(
53 (1.0 - s) * std::get<0>(t_a) + s * std::get<0>(t_b),
54 (1.0 - s) * std::get<1>(t_a) + s * std::get<1>(t_b),
55 (1.0 - s) * std::get<2>(t_a) + s * std::get<2>(t_b));
58 inline std::ostream& operator<<(std::ostream& os , hsv_t t)
60 os << std::get<0>(t) <<
" - " << std::get<1>(t) <<
" - " << std::get<2>(t);
67 #endif // end_of_include_guard
Namespace for the core simulator.