libvisual  0.5.0
lv_color_c.cpp
1 #include "config.h"
2 #include "lv_color.h"
3 #include "lv_common.h"
4 
5 extern "C" {
6 
7  VisColor* visual_color_new ()
8  {
9  return new LV::Color ();
10  }
11 
12  void visual_color_free (VisColor* color)
13  {
14  delete color;
15  }
16 
17  VisColor *visual_color_clone (VisColor* src)
18  {
19  visual_return_val_if_fail (src != nullptr, nullptr);
20 
21  return new LV::Color (*src);
22  }
23 
24  void visual_color_copy (VisColor* dest, VisColor* src)
25  {
26  visual_return_if_fail (dest != nullptr);
27  visual_return_if_fail (src != nullptr);
28 
29  *dest = *src;
30  }
31 
32  void visual_color_set (VisColor* color, uint8_t r, uint8_t g, uint8_t b)
33  {
34  visual_return_if_fail (color != nullptr);
35 
36  color->set (r, g, b);
37  }
38 
39  void visual_color_set_rgba (VisColor* color, uint8_t r, uint8_t g, uint8_t b, uint8_t a)
40  {
41  visual_return_if_fail (color != nullptr);
42 
43  color->set (r, g, b, a);
44  }
45 
46  int visual_color_compare (VisColor* src1, VisColor* src2)
47  {
48  visual_return_val_if_fail (src1 != nullptr, FALSE);
49  visual_return_val_if_fail (src2 != nullptr, FALSE);
50 
51  return ( *src1 == *src2 );
52  }
53 
54  void visual_color_set_hsv (VisColor* color, float h, float s, float v)
55  {
56  visual_return_if_fail (color != nullptr);
57 
58  color->set_hsv (h, s, v);
59  }
60 
61  void visual_color_get_hsv (VisColor* color, float* h, float* s, float* v)
62  {
63  visual_return_if_fail (color != nullptr);
64 
65  color->get_hsv (*h, *s, *v);
66  }
67 
68  void visual_color_set_from_uint32 (VisColor* color, uint32_t rgba)
69  {
70  visual_return_if_fail (color != nullptr);
71 
72  color->set_from_uint32 (rgba);
73  }
74 
75  void visual_color_set_from_uint16 (VisColor* color, uint16_t rgb)
76  {
77  visual_return_if_fail (color != nullptr);
78 
79  color->set_from_uint16 (rgb);
80  }
81 
82  uint32_t visual_color_to_uint32 (VisColor* color)
83  {
84  visual_return_val_if_fail (color != nullptr, 0);
85 
86  return color->to_uint32 ();
87  }
88 
89  uint16_t visual_color_to_uint16 (VisColor* color)
90  {
91  visual_return_val_if_fail (color != nullptr, 0);
92 
93  return color->to_uint16 ();
94  }
95 
96  VisColor* visual_color_black ()
97  {
98  return const_cast<VisColor*> (&LV::Color::black ());
99  }
100 
101  VisColor* visual_color_white ()
102  {
103  return const_cast<VisColor*> (&LV::Color::white ());
104  }
105 
106 } // C extern