Gazebo Msgs

API Reference

10.3.0
Color.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GZ_MSGS_CONVERT_COLOR_HH_
18 #define GZ_MSGS_CONVERT_COLOR_HH_
19 
20 // Message Headers
21 #include "gz/msgs/color.pb.h"
22 
23 // Data Headers
24 #include <gz/math/Color.hh>
25 
26 namespace gz::msgs {
27 // Inline bracket to help doxygen filtering.
28 inline namespace GZ_MSGS_VERSION_NAMESPACE {
29 
31 inline void Set(gz::msgs::Color *_msg, const gz::math::Color &_data)
32 {
33  _msg->set_r(_data.R());
34  _msg->set_g(_data.G());
35  _msg->set_b(_data.B());
36  _msg->set_a(_data.A());
37 }
38 
39 inline void Set(gz::math::Color *_data, const gz::msgs::Color &_msg)
40 {
41  _data->Set(_msg.r(), _msg.g(), _msg.b(), _msg.a());
42 }
43 
44 inline gz::msgs::Color Convert(const gz::math::Color &_data)
45 {
46  gz::msgs::Color ret;
47  Set(&ret, _data);
48  return ret;
49 }
50 
51 inline gz::math::Color Convert(const gz::msgs::Color &_msg)
52 {
53  gz::math::Color ret;
54  Set(&ret, _msg);
55  return ret;
56 }
57 } // namespce
58 } // namespace gz::msgs
59 
60 #endif // GZ_MSGS_CONVERT_VECTOR3_HH_