fj-core 0.49.0

Early-stage b-rep CAD kernel.
Documentation
//! Operations to control the presentation of objects

use fj_interop::Color;

use crate::{objects::Region, storage::Handle, Core};

/// Get the color of an object
pub trait GetColor {
    /// Get the color of the object
    fn get_color(&self, core: &mut Core) -> Option<Color>;
}

impl GetColor for Handle<Region> {
    fn get_color(&self, core: &mut Core) -> Option<Color> {
        core.layers.presentation.color.get(self).copied()
    }
}

/// Set the color of an object
pub trait SetColor {
    /// Set the color of the object
    fn set_color(&self, color: impl Into<Color>, core: &mut Core);
}

impl SetColor for Handle<Region> {
    fn set_color(&self, color: impl Into<Color>, core: &mut Core) {
        core.layers
            .presentation
            .set_color(self.clone(), color.into());
    }
}