Skip to main content

polyscope_rs/
floating.rs

1use crate::{Vec3, with_context_mut};
2
3/// Registers a floating scalar image (not attached to any structure).
4pub fn register_floating_scalar_image(
5    name: impl Into<String>,
6    width: u32,
7    height: u32,
8    values: Vec<f32>,
9) {
10    use polyscope_structures::floating::FloatingScalarImage;
11    let img = FloatingScalarImage::new(name, width, height, values);
12    with_context_mut(|ctx| {
13        ctx.floating_quantities.push(Box::new(img));
14    });
15}
16
17/// Registers a floating color image (not attached to any structure).
18pub fn register_floating_color_image(
19    name: impl Into<String>,
20    width: u32,
21    height: u32,
22    colors: Vec<Vec3>,
23) {
24    use polyscope_structures::floating::FloatingColorImage;
25    let img = FloatingColorImage::new(name, width, height, colors);
26    with_context_mut(|ctx| {
27        ctx.floating_quantities.push(Box::new(img));
28    });
29}
30
31/// Removes a floating quantity by name.
32pub fn remove_floating_quantity(name: &str) {
33    with_context_mut(|ctx| {
34        ctx.floating_quantities.retain(|q| q.name() != name);
35    });
36}
37
38/// Removes all floating quantities.
39pub fn remove_all_floating_quantities() {
40    with_context_mut(|ctx| {
41        ctx.floating_quantities.clear();
42    });
43}