add point + doc -> readme
This commit is contained in:
17
README.md
17
README.md
@@ -1,4 +1,21 @@
|
|||||||
# Polymusic
|
# Polymusic
|
||||||
|
|
||||||
|
## Instalation
|
||||||
|
|
||||||
|
>Install Rust and Cargo
|
||||||
|
>https://www.rust-lang.org/tools/install
|
||||||
|
|
||||||
|
```
|
||||||
|
cargo run
|
||||||
|
```
|
||||||
|
|
||||||
|
## Files
|
||||||
|
|
||||||
|
The `saves` folder contains all the saves, these are files that are not made to be edited outside of this software.
|
||||||
|
The `assets` folder contains all the sounds you can play. You can add more.
|
||||||
|
### Compatible Files
|
||||||
|
- MP3
|
||||||
|
- OGG Vorbis
|
||||||
|
- FLAC
|
||||||
|
- WAV
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ enum Message {
|
|||||||
SetMusicLength,
|
SetMusicLength,
|
||||||
LengthChange(String),
|
LengthChange(String),
|
||||||
ChangeDelta(f32),
|
ChangeDelta(f32),
|
||||||
|
AddPoint,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MyApp {
|
struct MyApp {
|
||||||
@@ -171,6 +172,9 @@ impl MyApp {
|
|||||||
self.update(Message::TogglePaused);
|
self.update(Message::TogglePaused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Message::AddPoint => {
|
||||||
|
self.music.add_Point(self.current_delta);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +316,8 @@ impl MyApp {
|
|||||||
delta_to_string(self.current_delta),
|
delta_to_string(self.current_delta),
|
||||||
delta_to_string(self.music.length)
|
delta_to_string(self.music.length)
|
||||||
))
|
))
|
||||||
.size(20.0)
|
.size(20.0),
|
||||||
|
button("Add Point").on_press(Message::AddPoint)
|
||||||
]
|
]
|
||||||
.spacing(20),
|
.spacing(20),
|
||||||
column![
|
column![
|
||||||
|
|||||||
14
src/music.rs
14
src/music.rs
@@ -52,10 +52,7 @@ impl Music {
|
|||||||
|
|
||||||
pub fn default() -> Music {
|
pub fn default() -> Music {
|
||||||
Music {
|
Music {
|
||||||
poly_frame: vec![
|
poly_frame: vec![(0.0, PolygonFrame::default())],
|
||||||
(0.0, PolygonFrame::default()),
|
|
||||||
(10.0, PolygonFrame::default()),
|
|
||||||
],
|
|
||||||
nb_sec_for_rev: 1.0,
|
nb_sec_for_rev: 1.0,
|
||||||
file_name: "Default Name".to_string(),
|
file_name: "Default Name".to_string(),
|
||||||
length: 60.0,
|
length: 60.0,
|
||||||
@@ -116,6 +113,15 @@ impl Music {
|
|||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ADD/REMOVE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~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) {
|
pub fn add_polygon(&mut self, delta: f32, polygon_name: String) {
|
||||||
let current_frame = self.find_poly_frame(delta);
|
let current_frame = self.find_poly_frame(delta);
|
||||||
let poly = string_to_polygon(polygon_name);
|
let poly = string_to_polygon(polygon_name);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl RotationExt for Vector {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
pub struct PolygonFrame {
|
pub struct PolygonFrame {
|
||||||
pub teta: f32,
|
pub teta: f32,
|
||||||
pub polygons: Vec<Polygon>,
|
pub polygons: Vec<Polygon>,
|
||||||
@@ -118,7 +118,7 @@ impl<Message> canvas::Program<Message> for PolygonFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct Polygon {
|
pub struct Polygon {
|
||||||
pub global_teta: f32,
|
pub global_teta: f32,
|
||||||
pub points_teta: Vec<f32>,
|
pub points_teta: Vec<f32>,
|
||||||
|
|||||||
Reference in New Issue
Block a user