color save

This commit is contained in:
2025-08-02 18:10:22 +02:00
parent f6185fca26
commit 5b4dbdbc16
4 changed files with 29 additions and 6 deletions

View File

@@ -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,