Rerun C++ SDK
Loading...
Searching...
No Matches
color.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/components/color.fbs".
3
4#pragma once
5
6#include "../component_descriptor.hpp"
7#include "../datatypes/rgba32.hpp"
8#include "../result.hpp"
9
10#include <cstdint>
11#include <memory>
12
13namespace rerun::components {
14 /// **Component**: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
15 ///
16 /// The color is stored as a 32-bit integer, where the most significant
17 /// byte is `R` and the least significant byte is `A`.
18 struct Color {
20
21 public: // START of extensions from color_ext.cpp:
22 /// Construct Color from unmultiplied RGBA values.
23 Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) : rgba(r, g, b, a) {}
24
25 uint8_t r() const {
26 return rgba.r();
27 }
28
29 uint8_t g() const {
30 return rgba.g();
31 }
32
33 uint8_t b() const {
34 return rgba.b();
35 }
36
37 uint8_t a() const {
38 return rgba.a();
39 }
40
41 // END of extensions from color_ext.cpp, start of generated code:
42
43 public:
44 Color() = default;
45
46 Color(rerun::datatypes::Rgba32 rgba_) : rgba(rgba_) {}
47
48 Color& operator=(rerun::datatypes::Rgba32 rgba_) {
49 rgba = rgba_;
50 return *this;
51 }
52
53 Color(uint32_t rgba_) : rgba(rgba_) {}
54
55 Color& operator=(uint32_t rgba_) {
56 rgba = rgba_;
57 return *this;
58 }
59
60 /// Cast to the underlying Rgba32 datatype
61 operator rerun::datatypes::Rgba32() const {
62 return rgba;
63 }
64 };
65} // namespace rerun::components
66
67namespace rerun {
68 static_assert(sizeof(rerun::datatypes::Rgba32) == sizeof(components::Color));
69
70 /// \private
71 template <>
72 struct Loggable<components::Color> {
73 static constexpr ComponentDescriptor Descriptor = "rerun.components.Color";
74
75 /// Returns the arrow data type this type corresponds to.
76 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
77 return Loggable<rerun::datatypes::Rgba32>::arrow_datatype();
78 }
79
80 /// Serializes an array of `rerun::components::Color` into an arrow array.
81 static Result<std::shared_ptr<arrow::Array>> to_arrow(
82 const components::Color* instances, size_t num_instances
83 ) {
84 if (num_instances == 0) {
85 return Loggable<rerun::datatypes::Rgba32>::to_arrow(nullptr, 0);
86 } else if (instances == nullptr) {
87 return rerun::Error(
88 ErrorCode::UnexpectedNullArgument,
89 "Passed array instances is null when num_elements> 0."
90 );
91 } else {
92 return Loggable<rerun::datatypes::Rgba32>::to_arrow(
93 &instances->rgba,
94 num_instances
95 );
96 }
97 }
98 };
99} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:95
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:80
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:18
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Construct Color from unmultiplied RGBA values.
Definition color.hpp:23
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:28