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 "../datatypes/rgba32.hpp"
7#include "../result.hpp"
8
9#include <cstdint>
10#include <memory>
11
12namespace rerun::components {
13 /// **Component**: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
14 ///
15 /// The color is stored as a 32-bit integer, where the most significant
16 /// byte is `R` and the least significant byte is `A`.
17 struct Color {
19
20 public: // START of extensions from color_ext.cpp:
21 /// Construct Color from unmultiplied RGBA values.
22 Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) : rgba(r, g, b, a) {}
23
24 uint8_t r() const {
25 return rgba.r();
26 }
27
28 uint8_t g() const {
29 return rgba.g();
30 }
31
32 uint8_t b() const {
33 return rgba.b();
34 }
35
36 uint8_t a() const {
37 return rgba.a();
38 }
39
40 // END of extensions from color_ext.cpp, start of generated code:
41
42 public:
43 Color() = default;
44
45 Color(rerun::datatypes::Rgba32 rgba_) : rgba(rgba_) {}
46
47 Color& operator=(rerun::datatypes::Rgba32 rgba_) {
48 rgba = rgba_;
49 return *this;
50 }
51
52 Color(uint32_t rgba_) : rgba(rgba_) {}
53
54 Color& operator=(uint32_t rgba_) {
55 rgba = rgba_;
56 return *this;
57 }
58
59 /// Cast to the underlying Rgba32 datatype
60 operator rerun::datatypes::Rgba32() const {
61 return rgba;
62 }
63 };
64} // namespace rerun::components
65
66namespace rerun {
67 static_assert(sizeof(rerun::datatypes::Rgba32) == sizeof(components::Color));
68
69 /// \private
70 template <>
71 struct Loggable<components::Color> {
72 static constexpr const char Name[] = "rerun.components.Color";
73
74 /// Returns the arrow data type this type corresponds to.
75 static const std::shared_ptr<arrow::DataType>& arrow_datatype() {
76 return Loggable<rerun::datatypes::Rgba32>::arrow_datatype();
77 }
78
79 /// Serializes an array of `rerun::components::Color` into an arrow array.
80 static Result<std::shared_ptr<arrow::Array>> to_arrow(
81 const components::Color* instances, size_t num_instances
82 ) {
83 if (num_instances == 0) {
84 return Loggable<rerun::datatypes::Rgba32>::to_arrow(nullptr, 0);
85 } else if (instances == nullptr) {
86 return rerun::Error(
87 ErrorCode::UnexpectedNullArgument,
88 "Passed array instances is null when num_elements> 0."
89 );
90 } else {
91 return Loggable<rerun::datatypes::Rgba32>::to_arrow(
92 &instances->rgba,
93 num_instances
94 );
95 }
96 }
97 };
98} // 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:79
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:22
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:17
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Construct Color from unmultiplied RGBA values.
Definition color.hpp:22
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:27