Skip to content

Commit

Permalink
add rust version of point3d_ui_radius
Browse files Browse the repository at this point in the history
  • Loading branch information
Wumpf committed Jul 1, 2024
1 parent 0e8936a commit ce83e0f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
14 changes: 7 additions & 7 deletions docs/snippets/all/archetypes/point3d_ui_radius.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Log some points with ui & world-space radii."""
"""Log some points with ui points & scene unit radii."""

import rerun as rr

rr.init("rerun_example_points3d_ui_radius", spawn=True)

# Two blue points with world-space radii of 0.1 and 0.3.
# Two blue points with scene unit radii of 0.1 and 0.3.
rr.log(
"world_sized_points",
"scene_unit_points",
rr.Points3D(
[[0, 1, 0], [1, 1, 1]],
# By default, radii are interpreted as world-space units.
Expand All @@ -15,11 +15,11 @@
),
)

# Two red points with ui radii of 40 and 60.
# Ui units are independent of zooming in Views, but are sensitive to the application ui scaling.
# For 100% ui scaling, ui units are equal to pixels.
# Two red points with ui point radii of 40 and 60.
# Ui points are independent of zooming in Views, but are sensitive to the application ui scaling.
# For 100% ui scaling, ui points are equal to pixels.
rr.log(
"ui_sized_points",
"ui_points_points",
rr.Points3D(
[[0, 0, 0], [1, 0, 1]],
# rr.Radius.ui_points produces radii that the viewer interprets as given in ui units.
Expand Down
28 changes: 22 additions & 6 deletions docs/snippets/all/archetypes/point3d_ui_radius.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
//! Log some very simple points.
//! Log some points with ui points & scene unit radii.
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_points3d_ui_radius").spawn()?;

// Two blue points with scene unit radii of 0.1 and 0.3.
rec.log(
"points",
&rerun::Points3D::new([(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)]),
)?;
"scene_unit_points",
&rerun::Points3D::new([(0.0, 1.0, 0.0), (1.0, 1.0, 1.0)])
// By default, radii are interpreted as world-space units.
.with_radii([0.1, 0.3])
.with_colors([rerun::Color::from_rgb(0, 0, 255)]),
);

// Two red points with ui point radii of 40 and 60.
// Ui points are independent of zooming in Views, but are sensitive to the application ui scaling.
// For 100% ui scaling, ui points are equal to pixels.
rec.log(
"ui_points_points",
&rerun::Points3D::new([(0.0, 0.0, 0.0), (1.0, 0.0, 1.0)])
// rr.Radius.ui_points produces radii that the viewer interprets as given in ui units.
.with_radii([
rerun::Radius::new_ui_points(40.0),
rerun::Radius::new_ui_points(60.0),
])
.with_colors([rerun::Color::from_rgb(255, 0, 0)]),
);

Ok(())
}

// TODO: unfinished

0 comments on commit ce83e0f

Please sign in to comment.