Rerun C++ SDK
Loading...
Searching...
No Matches
color.hpp
1// DO NOT EDIT! This file was auto-generated by crates/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/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 arrow {
13 /// \private
14 template <typename T>
15 class NumericBuilder;
16
17 class Array;
18 class DataType;
19 class UInt32Type;
20 using UInt32Builder = NumericBuilder<UInt32Type>;
21} // namespace arrow
22
23namespace rerun::components {
24 /// **Component**: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
25 ///
26 /// The color is stored as a 32-bit integer, where the most significant
27 /// byte is `R` and the least significant byte is `A`.
28 struct Color {
30
31 public:
32 // Extensions to generated type defined in 'color_ext.cpp'
33
34 /// Construct Color from unmultiplied RGBA values.
35 Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) : rgba(r, g, b, a) {}
36
37 uint8_t r() const {
38 return rgba.r();
39 }
40
41 uint8_t g() const {
42 return rgba.g();
43 }
44
45 uint8_t b() const {
46 return rgba.b();
47 }
48
49 uint8_t a() const {
50 return rgba.a();
51 }
52
53 public:
54 Color() = default;
55
56 Color(rerun::datatypes::Rgba32 rgba_) : rgba(rgba_) {}
57
58 Color& operator=(rerun::datatypes::Rgba32 rgba_) {
59 rgba = rgba_;
60 return *this;
61 }
62
63 Color(uint32_t rgba_) : rgba(rgba_) {}
64
65 Color& operator=(uint32_t rgba_) {
66 rgba = rgba_;
67 return *this;
68 }
69
70 /// Cast to the underlying Rgba32 datatype
71 operator rerun::datatypes::Rgba32() const {
72 return rgba;
73 }
74 };
75} // namespace rerun::components
76
77namespace rerun {
78 template <typename T>
79 struct Loggable;
80
81 /// \private
82 template <>
83 struct Loggable<components::Color> {
84 static constexpr const char Name[] = "rerun.components.Color";
85
86 /// Returns the arrow data type this type corresponds to.
87 static const std::shared_ptr<arrow::DataType>& arrow_datatype();
88
89 /// Fills an arrow array builder with an array of this type.
90 static rerun::Error fill_arrow_array_builder(
91 arrow::UInt32Builder* builder, const components::Color* elements, size_t num_elements
92 );
93
94 /// Serializes an array of `rerun::components::Color` into an arrow array.
95 static Result<std::shared_ptr<arrow::Array>> to_arrow(
96 const components::Color* instances, size_t num_instances
97 );
98 };
99} // namespace rerun
Status outcome object (success or error) returned for fallible operations.
Definition error.hpp:87
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:69
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:20
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:28
Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
Construct Color from unmultiplied RGBA values.
Definition color.hpp:35
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:27