Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ea2ab483b | |||
| e81e92a6bc | |||
| 814bfa0e05 |
@@ -15,7 +15,7 @@ Polymusic is an innovative music application inspired
|
||||
cargo run
|
||||
```
|
||||
### Release
|
||||
Release is available on gitlab. Download windows ou linux version.
|
||||
Release is available on gitlab. Download windows or linux version.
|
||||
Execute `Polymusic` or `Polymusic.exe`
|
||||
|
||||
## Files
|
||||
|
||||
22
src/color.rs
Normal file
22
src/color.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use iced::Color;
|
||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
pub mod color_serde {
|
||||
use super::*;
|
||||
|
||||
pub fn serialize<S>(color: &Color, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
let data = [color.r, color.g, color.b, color.a];
|
||||
data.serialize(serializer)
|
||||
}
|
||||
|
||||
pub fn deserialize<'de, D>(deserializer: D) -> Result<Color, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let data: [f32; 4] = Deserialize::deserialize(deserializer)?;
|
||||
Ok(Color::from_rgba(data[0], data[1], data[2], data[3]))
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ use polygon_draw::Polygon;
|
||||
mod music;
|
||||
use music::Music;
|
||||
|
||||
mod color;
|
||||
|
||||
mod history;
|
||||
use history::Historic;
|
||||
|
||||
|
||||
1
src/main.rs.lock~
Normal file
1
src/main.rs.lock~
Normal file
@@ -0,0 +1 @@
|
||||
dukantic@templeos
|
||||
@@ -1,12 +1,13 @@
|
||||
use crate::utils::string_to_color;
|
||||
|
||||
use crate::color::color_serde;
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use iced::Size;
|
||||
use iced::Vector;
|
||||
use iced::mouse;
|
||||
use iced::widget::canvas;
|
||||
use iced::widget::canvas::{Frame, Stroke, Style};
|
||||
use iced::Size;
|
||||
use iced::Vector;
|
||||
use iced::{Color, Point, Rectangle, Renderer, Theme};
|
||||
use kira::sound::static_sound::StaticSoundData;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -191,9 +192,8 @@ pub struct Polygon {
|
||||
pub sound: StaticSoundData,
|
||||
pub sound_name: String,
|
||||
pub name: String,
|
||||
#[serde(skip)]
|
||||
#[serde(with = "color_serde")]
|
||||
pub color: Color,
|
||||
pub color_name: String,
|
||||
#[serde(skip)]
|
||||
pub show_color_picker: bool,
|
||||
}
|
||||
@@ -202,7 +202,6 @@ impl Polygon {
|
||||
pub fn update(&mut self) {
|
||||
let path = format!("./assets/{0}", &self.sound_name);
|
||||
self.sound = StaticSoundData::from_file(&path).expect("fail to load the sound");
|
||||
self.color = string_to_color(&self.color_name);
|
||||
}
|
||||
pub fn sound_to_play_btw(&self, before: f32, after: f32) -> Vec<&StaticSoundData> {
|
||||
let mut sound_to_play: Vec<&StaticSoundData> = vec![];
|
||||
@@ -226,7 +225,6 @@ impl Polygon {
|
||||
points_teta: vec![],
|
||||
sound: sound,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
show_color_picker: false,
|
||||
|
||||
Reference in New Issue
Block a user