color.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2021 by
  4. * The Salk Institute for Biological Studies
  5. *
  6. * Use of this source code is governed by an MIT-style
  7. * license that can be found in the LICENSE file or at
  8. * https://opensource.org/licenses/MIT.
  9. *
  10. ******************************************************************************/
  11. #ifndef API_COLOR_H
  12. #define API_COLOR_H
  13. #include "generated/gen_color.h"
  14. #include "api/api_common.h"
  15. namespace MCell {
  16. namespace API {
  17. class Color: public GenColor {
  18. public:
  19. COLOR_CTOR()
  20. void postprocess_in_ctor() override;
  21. void set_red(const double new_red_) override {
  22. red = new_red_;
  23. components_to_rgba();
  24. }
  25. void set_green(const double new_green_) override {
  26. green = new_green_;
  27. components_to_rgba();
  28. }
  29. void set_blue(const double new_blue_) override {
  30. blue = new_blue_;
  31. components_to_rgba();
  32. }
  33. void set_alpha(const double new_alpha_) override {
  34. alpha = new_alpha_;
  35. components_to_rgba();
  36. }
  37. void set_rgba(const uint new_rgba_) override {
  38. rgba = new_rgba_;
  39. rgba_to_components();
  40. }
  41. private:
  42. void components_to_rgba();
  43. void rgba_to_components();
  44. void check_component_range(const double value, const char* name);
  45. };
  46. } // namespace API
  47. } // namespace MCell
  48. #endif // API_COLOR_H