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 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:
21 // Extensions to generated type defined in 'color_ext.cpp'
22
23 /// Construct Color from unmultiplied RGBA values.
24 Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) : rgba(r, g, b, a) {}
25
26 uint8_t r() const {
27 return rgba.r();
28 }
29
30 uint8_t g() const {
31 return rgba.g();
32 }
33
34 uint8_t b() const {
35 return rgba.b();
36 }
37
38 uint8_t a() const {
39 return rgba.a();
40 }
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 return Loggable<rerun::datatypes::Rgba32>::to_arrow(&instances->rgba, num_instances);
84 }
85 };
86} // namespace rerun
All built-in components. See Types in the Rerun manual.
Definition rerun.hpp:75
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:21
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:24
Datatype: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition rgba32.hpp:27