Skip to content

Commit

Permalink
Add color model
Browse files Browse the repository at this point in the history
  • Loading branch information
hannobraun committed Jan 17, 2024
1 parent a9c15d9 commit 3982783
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"crates/fj-window",

"models/all",
"models/color",
"models/cuboid",
"models/holes",
"models/spacer",
Expand Down
11 changes: 11 additions & 0 deletions models/color/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "color"
version = "0.1.0"
edition = "2021"


[dependencies.cuboid]
path = "../cuboid"

[dependencies.fj]
path = "../../crates/fj"
35 changes: 35 additions & 0 deletions models/color/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use fj::{
core::{
objects::{Region, Solid},
operations::{
insert::Insert,
update::{UpdateFace, UpdateShell, UpdateSolid},
},
services::Services,
storage::Handle,
},
interop::Color,
};

pub fn model(services: &mut Services) -> Handle<Solid> {
let size = 1.;
let cuboid = cuboid::model([size, size, size], services);

cuboid
.update_shell(cuboid.shells().only(), |shell| {
shell
.update_face(shell.faces().first(), |face| {
face.update_region(|region| {
Region::new(
region.exterior().clone(),
region.interiors().into_iter().cloned(),
Some(Color::from([0., 1., 0.])),
)
.insert(services)
})
.insert(services)
})
.insert(services)
})
.insert(services)
}
8 changes: 8 additions & 0 deletions models/color/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use fj::{core::services::Services, handle_model};

fn main() -> fj::Result {
let mut services = Services::new();
let model = color::model(&mut services);
handle_model(model, services)?;
Ok(())
}

0 comments on commit 3982783

Please sign in to comment.