diff --git a/Cargo.lock b/Cargo.lock index f39a719e5a742..1a250e41f9d8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3729,7 +3729,7 @@ dependencies = [ "pyo3-build-config", "pyo3-ffi", "pyo3-macros", - "unindent 0.1.11", + "unindent", ] [[package]] @@ -3938,7 +3938,7 @@ dependencies = [ "glob", "sha2", "time", - "unindent 0.1.11", + "unindent", "walkdir", ] @@ -4225,7 +4225,7 @@ dependencies = [ "thiserror", "tobj", "type-map", - "unindent 0.2.1", + "unindent", "walkdir", "wasm-bindgen-futures", "web-sys", @@ -4505,7 +4505,7 @@ dependencies = [ "flatbuffers", "indent", "re_build_tools", - "unindent 0.2.1", + "unindent", "xshell", ] @@ -5799,12 +5799,6 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" -[[package]] -name = "unindent" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa30f5ea51ff7edfc797c6d3f9ec8cbd8cfedef5371766b7181d33977f4814f" - [[package]] name = "untrusted" version = "0.7.1" diff --git a/Cargo.toml b/Cargo.toml index 425286b47697c..13b1df640125f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,6 +110,7 @@ time = { version = "0.3", default-features = false, features = [ ] } tinyvec = { version = "1.6", features = ["alloc", "rustc_1_55"] } tokio = { version = "1.24", default-features = false } +unindent = "0.1" vec1 = "1.8" web-time = "0.2.0" wgpu = { version = "0.16.1" } diff --git a/crates/re_renderer/Cargo.toml b/crates/re_renderer/Cargo.toml index 88a9c4bce12c9..5549b4f5a9500 100644 --- a/crates/re_renderer/Cargo.toml +++ b/crates/re_renderer/Cargo.toml @@ -92,7 +92,7 @@ winit = "0.28.1" zip = { version = "0.6", default-features = false, features = ["deflate"] } # For tests: -unindent = "0.1" +unindent.workspace = true # native [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] diff --git a/crates/re_types_builder/Cargo.toml b/crates/re_types_builder/Cargo.toml index 01b3cc8efc4a5..ffdd334219bd8 100644 --- a/crates/re_types_builder/Cargo.toml +++ b/crates/re_types_builder/Cargo.toml @@ -25,7 +25,7 @@ arrow2.workspace = true convert_case = "0.6" flatbuffers = "23.0" indent = "0.1" -unindent = "0.2" +unindent.workspace = true xshell = "0.2" diff --git a/rerun_py/rerun_sdk/rerun/color_conversion.py b/rerun_py/rerun_sdk/rerun/color_conversion.py index acebb0560b7d7..50764bf7293ba 100644 --- a/rerun_py/rerun_sdk/rerun/color_conversion.py +++ b/rerun_py/rerun_sdk/rerun/color_conversion.py @@ -1,10 +1,32 @@ """Color conversion utilities.""" -from typing import Union +from typing import List, Union import numpy as np import numpy.typing as npt +def rgba_to_u8_array(rgba: np.uint32) -> List[np.uint8]: + """ + Convert a uint32 into an array[4] of uint8 values. + + Parameters + ---------- + rgba: int + The uint32 value as 0xRRGGBBAA. + + Returns + ------- + List[int] + The array of uint8 values converted in RGBA order. + + """ + red = rgba >> 24 & 0xFF + green = rgba >> 16 & 0xFF + blue = rgba >> 8 & 0xFF + alpha = rgba & 0xFF + return [red, green, blue, alpha] # type: ignore[return-value] + + def u8_array_to_rgba(arr: npt.NDArray[np.uint8]) -> npt.NDArray[np.uint32]: """ Convert an array with inner dimension [R,G,B,A] into packed uint32 values.