CARLA
rpc/Color.h
Go to the documentation of this file.
1 // Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma
2 // de Barcelona (UAB).
3 //
4 // This work is licensed under the terms of the MIT license.
5 // For a copy, see <https://opensource.org/licenses/MIT>.
6 
7 #pragma once
8 
9 #include "carla/MsgPack.h"
10 
11 #include <cstdint>
12 
13 #ifdef LIBCARLA_INCLUDED_FROM_UE4
14 # include "Math/Color.h"
15 #endif // LIBCARLA_INCLUDED_FROM_UE4
16 
17 namespace carla {
18 namespace rpc {
19 
20  class Color {
21  public:
22 
23  uint8_t r = 0u;
24  uint8_t g = 0u;
25  uint8_t b = 0u;
26 
27  Color() = default;
28  Color(const Color &) = default;
29 
30  Color(uint8_t r, uint8_t g, uint8_t b)
31  : r(r), g(g), b(b) {}
32 
33  Color &operator=(const Color &) = default;
34 
35 #ifdef LIBCARLA_INCLUDED_FROM_UE4
36 
37  Color(const FColor &color)
38  : Color(color.R, color.G, color.B) {}
39 
40  Color(const FLinearColor &color)
41  : Color(color.R * 255.0f, color.G * 255.0f, color.B * 255.0f) {}
42 
43  operator FColor() const {
44  return FColor{r, g, b};
45  }
46 
47  operator FLinearColor() const {
48  return FLinearColor{
49  static_cast<float>(r)/255.0f,
50  static_cast<float>(g)/255.0f,
51  static_cast<float>(b)/255.0f,
52  1.0f
53  };
54  }
55 
56 #endif // LIBCARLA_INCLUDED_FROM_UE4
57 
58  MSGPACK_DEFINE_ARRAY(r, g, b);
59  };
60 
61 } // namespace rpc
62 } // namespace carla
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
Color(uint8_t r, uint8_t g, uint8_t b)
Definition: rpc/Color.h:30
MSGPACK_DEFINE_ARRAY(r, g, b)
Color & operator=(const Color &)=default