Bézier-rs: Add ids to manipulator groups (#1054)

* Add ids to manipulator groups

* Fix tests

* Rename trait from ManipulatorGroupId to Identifier

* Rename EmptyManipulatorGroupId to EmptyId
This commit is contained in:
0HyperCube 2023-02-25 16:23:58 +00:00 committed by Keavon Chambers
parent 7a52e50a94
commit 08b2782917
8 changed files with 93 additions and 27 deletions

View file

@ -6,9 +6,18 @@ use glam::DVec2;
use std::fmt::Write;
use wasm_bindgen::prelude::*;
#[derive(Clone, PartialEq)]
pub(crate) struct EmptyId;
impl bezier_rs::Identifier for EmptyId {
fn new() -> Self {
Self
}
}
/// Wrapper of the `Subpath` struct to be used in JS.
#[wasm_bindgen]
pub struct WasmSubpath(Subpath);
pub struct WasmSubpath(Subpath<EmptyId>);
const SCALE_UNIT_VECTOR_FACTOR: f64 = 50.;
@ -31,6 +40,7 @@ impl WasmSubpath {
anchor: point_triple[0].unwrap(),
in_handle: point_triple[1],
out_handle: point_triple[2],
id: EmptyId,
})
.collect();
WasmSubpath(Subpath::new(manipulator_groups, closed))