add point + doc -> readme

This commit is contained in:
2025-07-08 22:37:28 +02:00
parent 26a96fd933
commit 87f1b56eac
4 changed files with 35 additions and 7 deletions

View File

@@ -52,10 +52,7 @@ impl Music {
pub fn default() -> Music {
Music {
poly_frame: vec![
(0.0, PolygonFrame::default()),
(10.0, PolygonFrame::default()),
],
poly_frame: vec![(0.0, PolygonFrame::default())],
nb_sec_for_rev: 1.0,
file_name: "Default Name".to_string(),
length: 60.0,
@@ -116,6 +113,15 @@ impl Music {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ADD/REMOVE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pub fn add_Point(&mut self, delta: f32) {
let pos = self
.poly_frame
.binary_search_by(|(d, _)| d.partial_cmp(&delta).unwrap())
.unwrap_or_else(|e| e);
self.poly_frame
.insert(pos, (delta, self.current_frame(delta).clone()));
}
pub fn add_polygon(&mut self, delta: f32, polygon_name: String) {
let current_frame = self.find_poly_frame(delta);
let poly = string_to_polygon(polygon_name);