Struct re_types::archetypes::Points2D
source · pub struct Points2D {
pub positions: Vec<Position2D>,
pub radii: Option<Vec<Radius>>,
pub colors: Option<Vec<Color>>,
pub labels: Option<Vec<Text>>,
pub draw_order: Option<DrawOrder>,
pub class_ids: Option<Vec<ClassId>>,
pub keypoint_ids: Option<Vec<KeypointId>>,
pub instance_keys: Option<Vec<InstanceKey>>,
}Expand description
Archetype: A 2D point cloud with positions and optional colors, radii, labels, etc.
Example
Randomly distributed 2D points with varying color and radius
//! Log some random points with color and radii.
use rand::{distributions::Uniform, Rng as _};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let (rec, storage) = rerun::RecordingStreamBuilder::new("rerun_example_points2d").memory()?;
let mut rng = rand::thread_rng();
let dist = Uniform::new(-3., 3.);
rec.log(
"random",
&rerun::Points2D::new((0..10).map(|_| (rng.sample(dist), rng.sample(dist))))
.with_colors((0..10).map(|_| rerun::Color::from_rgb(rng.gen(), rng.gen(), rng.gen())))
.with_radii((0..10).map(|_| rng.gen::<f32>())),
)?;
// Log an extra rect to set the view bounds
rec.log("bounds", &rerun::Boxes2D::from_half_sizes([(4., 3.)]))?;
rerun::native_viewer::show(storage.take())?;
Ok(())
}Fields§
§positions: Vec<Position2D>All the 2D positions at which the point cloud shows points.
radii: Option<Vec<Radius>>Optional radii for the points, effectively turning them into circles.
colors: Option<Vec<Color>>Optional colors for the points.
labels: Option<Vec<Text>>Optional text labels for the points.
draw_order: Option<DrawOrder>An optional floating point value that specifies the 2D drawing order.
Objects with higher values are drawn on top of those with lower values.
class_ids: Option<Vec<ClassId>>Optional class Ids for the points.
The class ID provides colors and labels if not specified explicitly.
keypoint_ids: Option<Vec<KeypointId>>Optional keypoint IDs for the points, identifying them within a class.
If keypoint IDs are passed in but no class IDs were specified, the class ID will
default to 0.
This is useful to identify points within a single classification (which is identified
with class_id).
E.g. the classification might be ‘Person’ and the keypoints refer to joints on a
detected skeleton.
instance_keys: Option<Vec<InstanceKey>>Unique identifiers for each individual point in the batch.
Implementations§
source§impl Points2D
impl Points2D
pub fn new(positions: impl IntoIterator<Item = impl Into<Position2D>>) -> Self
pub fn with_radii( self, radii: impl IntoIterator<Item = impl Into<Radius>> ) -> Self
pub fn with_colors( self, colors: impl IntoIterator<Item = impl Into<Color>> ) -> Self
pub fn with_labels( self, labels: impl IntoIterator<Item = impl Into<Text>> ) -> Self
pub fn with_draw_order(self, draw_order: impl Into<DrawOrder>) -> Self
pub fn with_class_ids( self, class_ids: impl IntoIterator<Item = impl Into<ClassId>> ) -> Self
pub fn with_keypoint_ids( self, keypoint_ids: impl IntoIterator<Item = impl Into<KeypointId>> ) -> Self
pub fn with_instance_keys( self, instance_keys: impl IntoIterator<Item = impl Into<InstanceKey>> ) -> Self
Trait Implementations§
source§impl Archetype for Points2D
impl Archetype for Points2D
§type Indicator = GenericIndicatorComponent<Points2D>
type Indicator = GenericIndicatorComponent<Points2D>
source§fn name() -> ArchetypeName
fn name() -> ArchetypeName
rerun.archetypes.Points2D.source§fn indicator() -> MaybeOwnedComponentBatch<'static>
fn indicator() -> MaybeOwnedComponentBatch<'static>
source§fn required_components() -> Cow<'static, [ComponentName]>
fn required_components() -> Cow<'static, [ComponentName]>
source§fn recommended_components() -> Cow<'static, [ComponentName]>
fn recommended_components() -> Cow<'static, [ComponentName]>
source§fn optional_components() -> Cow<'static, [ComponentName]>
fn optional_components() -> Cow<'static, [ComponentName]>
source§fn all_components() -> Cow<'static, [ComponentName]>
fn all_components() -> Cow<'static, [ComponentName]>
source§fn from_arrow(
arrow_data: impl IntoIterator<Item = (Field, Box<dyn Array>)>
) -> DeserializationResult<Self>
fn from_arrow( arrow_data: impl IntoIterator<Item = (Field, Box<dyn Array>)> ) -> DeserializationResult<Self>
source§impl AsComponents for Points2D
impl AsComponents for Points2D
source§fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
fn as_component_batches(&self) -> Vec<MaybeOwnedComponentBatch<'_>>
ComponentBatchs. Read more