add color picker and better buttons
This commit is contained in:
@@ -194,6 +194,7 @@ pub struct Polygon {
|
||||
#[serde(skip)]
|
||||
pub color: Color,
|
||||
pub color_name: String,
|
||||
pub show_color_picker: bool,
|
||||
}
|
||||
#[warn(dead_code)]
|
||||
impl Polygon {
|
||||
@@ -218,196 +219,154 @@ impl Polygon {
|
||||
}
|
||||
sound_to_play
|
||||
}
|
||||
pub fn default(sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
global_teta: 0.,
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn n_gon(teta: f32, n_side: u8, sound: StaticSoundData) -> Self {
|
||||
pub fn n_gon(n_side: u8, sound: StaticSoundData) -> Self {
|
||||
let mut v: Vec<f32> = Vec::with_capacity(n_side as usize);
|
||||
for i in 0..n_side {
|
||||
v.push((i as f32 * 2.0 * PI) / n_side as f32);
|
||||
}
|
||||
Polygon {
|
||||
global_teta: teta,
|
||||
points_teta: v,
|
||||
sound: sound,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
}
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = v;
|
||||
p
|
||||
}
|
||||
pub fn segment(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon::n_gon(teta, 2, sound)
|
||||
pub fn segment(sound: StaticSoundData) -> Self {
|
||||
Polygon::n_gon(2, sound)
|
||||
}
|
||||
|
||||
pub fn triangle(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon::n_gon(teta, 3, sound)
|
||||
pub fn triangle(sound: StaticSoundData) -> Self {
|
||||
Polygon::n_gon(3, sound)
|
||||
}
|
||||
|
||||
pub fn square(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon::n_gon(teta, 4, sound)
|
||||
pub fn square(sound: StaticSoundData) -> Self {
|
||||
Polygon::n_gon(4, sound)
|
||||
}
|
||||
|
||||
pub fn nr_6_in_30(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
global_teta: teta,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
points_teta: vec![
|
||||
2.0 * 5.0 * PI / 30.0,
|
||||
2.0 * 6.0 * PI / 30.0,
|
||||
2.0 * 12.0 * PI / 30.0,
|
||||
2.0 * 18.0 * PI / 30.0,
|
||||
2.0 * 24.0 * PI / 30.0,
|
||||
2.0 * 25.0 * PI / 30.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_6_in_30(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
2.0 * 5.0 * PI / 30.0,
|
||||
2.0 * 6.0 * PI / 30.0,
|
||||
2.0 * 12.0 * PI / 30.0,
|
||||
2.0 * 18.0 * PI / 30.0,
|
||||
2.0 * 24.0 * PI / 30.0,
|
||||
2.0 * 25.0 * PI / 30.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
pub fn nr_7_in_30(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
global_teta: teta,
|
||||
points_teta: vec![
|
||||
0.0,
|
||||
2.0 * 6.0 * PI / 30.0,
|
||||
2.0 * 7.0 * PI / 30.0,
|
||||
2.0 * 13.0 * PI / 30.0,
|
||||
2.0 * 17.0 * PI / 30.0,
|
||||
2.0 * 23.0 * PI / 30.0,
|
||||
2.0 * 24.0 * PI / 30.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_7_in_30(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
0.0,
|
||||
2.0 * 6.0 * PI / 30.0,
|
||||
2.0 * 7.0 * PI / 30.0,
|
||||
2.0 * 13.0 * PI / 30.0,
|
||||
2.0 * 17.0 * PI / 30.0,
|
||||
2.0 * 23.0 * PI / 30.0,
|
||||
2.0 * 24.0 * PI / 30.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
pub fn nr_8_in_30(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
global_teta: teta,
|
||||
points_teta: vec![
|
||||
2.0 * PI / 30.0,
|
||||
2.0 * 5.0 * PI / 30.0,
|
||||
2.0 * 11.0 * PI / 30.0,
|
||||
2.0 * 12.0 * PI / 30.0,
|
||||
2.0 * 18.0 * PI / 30.0,
|
||||
2.0 * 19.0 * PI / 30.0,
|
||||
2.0 * 25.0 * PI / 30.0,
|
||||
2.0 * 29.0 * PI / 30.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_8_in_30(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
2.0 * PI / 30.0,
|
||||
2.0 * 5.0 * PI / 30.0,
|
||||
2.0 * 11.0 * PI / 30.0,
|
||||
2.0 * 12.0 * PI / 30.0,
|
||||
2.0 * 18.0 * PI / 30.0,
|
||||
2.0 * 19.0 * PI / 30.0,
|
||||
2.0 * 25.0 * PI / 30.0,
|
||||
2.0 * 29.0 * PI / 30.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
pub fn nr_9_in_30(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
global_teta: teta,
|
||||
points_teta: vec![
|
||||
0.0,
|
||||
2.0 * PI / 30.0,
|
||||
2.0 * 7.0 * PI / 30.0,
|
||||
2.0 * 11.0 * PI / 30.0,
|
||||
2.0 * 13.0 * PI / 30.0,
|
||||
2.0 * 17.0 * PI / 30.0,
|
||||
2.0 * 19.0 * PI / 30.0,
|
||||
2.0 * 23.0 * PI / 30.0,
|
||||
2.0 * 29.0 * PI / 30.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_9_in_30(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
0.0,
|
||||
2.0 * PI / 30.0,
|
||||
2.0 * 7.0 * PI / 30.0,
|
||||
2.0 * 11.0 * PI / 30.0,
|
||||
2.0 * 13.0 * PI / 30.0,
|
||||
2.0 * 17.0 * PI / 30.0,
|
||||
2.0 * 19.0 * PI / 30.0,
|
||||
2.0 * 23.0 * PI / 30.0,
|
||||
2.0 * 29.0 * PI / 30.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
pub fn nr_8_in_42(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
global_teta: teta,
|
||||
points_teta: vec![
|
||||
2.0 * 3.0 * PI / 42.0,
|
||||
2.0 * 9.0 * PI / 42.0,
|
||||
2.0 * 14.0 * PI / 42.0,
|
||||
2.0 * 15.0 * PI / 42.0,
|
||||
2.0 * 27.0 * PI / 42.0,
|
||||
2.0 * 28.0 * PI / 42.0,
|
||||
2.0 * 33.0 * PI / 42.0,
|
||||
2.0 * 39.0 * PI / 42.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_8_in_42(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
2.0 * 3.0 * PI / 42.0,
|
||||
2.0 * 9.0 * PI / 42.0,
|
||||
2.0 * 14.0 * PI / 42.0,
|
||||
2.0 * 15.0 * PI / 42.0,
|
||||
2.0 * 27.0 * PI / 42.0,
|
||||
2.0 * 28.0 * PI / 42.0,
|
||||
2.0 * 33.0 * PI / 42.0,
|
||||
2.0 * 39.0 * PI / 42.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
pub fn nr_9_in_42(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
global_teta: teta,
|
||||
points_teta: vec![
|
||||
0.0,
|
||||
2.0 * 6.0 * PI / 42.0,
|
||||
2.0 * 11.0 * PI / 42.0,
|
||||
2.0 * 12.0 * PI / 42.0,
|
||||
2.0 * 17.0 * PI / 42.0,
|
||||
2.0 * 25.0 * PI / 42.0,
|
||||
2.0 * 30.0 * PI / 42.0,
|
||||
2.0 * 31.0 * PI / 42.0,
|
||||
2.0 * 36.0 * PI / 42.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_9_in_42(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
0.0,
|
||||
2.0 * 6.0 * PI / 42.0,
|
||||
2.0 * 11.0 * PI / 42.0,
|
||||
2.0 * 12.0 * PI / 42.0,
|
||||
2.0 * 17.0 * PI / 42.0,
|
||||
2.0 * 25.0 * PI / 42.0,
|
||||
2.0 * 30.0 * PI / 42.0,
|
||||
2.0 * 31.0 * PI / 42.0,
|
||||
2.0 * 36.0 * PI / 42.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
pub fn nr_10a_in_42(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
global_teta: teta,
|
||||
points_teta: vec![
|
||||
2.0 * 6.0 * PI / 42.0,
|
||||
2.0 * 7.0 * PI / 42.0,
|
||||
2.0 * 11.0 * PI / 42.0,
|
||||
2.0 * 12.0 * PI / 42.0,
|
||||
2.0 * 17.0 * PI / 42.0,
|
||||
2.0 * 25.0 * PI / 42.0,
|
||||
2.0 * 30.0 * PI / 42.0,
|
||||
2.0 * 31.0 * PI / 42.0,
|
||||
2.0 * 35.0 * PI / 42.0,
|
||||
2.0 * 36.0 * PI / 42.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_10a_in_42(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
2.0 * 6.0 * PI / 42.0,
|
||||
2.0 * 7.0 * PI / 42.0,
|
||||
2.0 * 11.0 * PI / 42.0,
|
||||
2.0 * 12.0 * PI / 42.0,
|
||||
2.0 * 17.0 * PI / 42.0,
|
||||
2.0 * 25.0 * PI / 42.0,
|
||||
2.0 * 30.0 * PI / 42.0,
|
||||
2.0 * 31.0 * PI / 42.0,
|
||||
2.0 * 35.0 * PI / 42.0,
|
||||
2.0 * 36.0 * PI / 42.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
pub fn nr_10b_in_42(teta: f32, sound: StaticSoundData) -> Self {
|
||||
Polygon {
|
||||
sound: sound,
|
||||
name: "".to_string(),
|
||||
color: Color::BLACK,
|
||||
sound_name: "tick.ogg".to_string(),
|
||||
color_name: "Black".to_string(),
|
||||
global_teta: teta,
|
||||
points_teta: vec![
|
||||
0.0,
|
||||
2.0 * 1.0 * PI / 42.0,
|
||||
2.0 * 5.0 * PI / 42.0,
|
||||
2.0 * 13.0 * PI / 42.0,
|
||||
2.0 * 18.0 * PI / 42.0,
|
||||
2.0 * 19.0 * PI / 42.0,
|
||||
2.0 * 24.0 * PI / 42.0,
|
||||
2.0 * 29.0 * PI / 42.0,
|
||||
2.0 * 30.0 * PI / 42.0,
|
||||
2.0 * 41.0 * PI / 42.0,
|
||||
],
|
||||
}
|
||||
pub fn nr_10b_in_42(sound: StaticSoundData) -> Self {
|
||||
let mut p = Polygon::default(sound);
|
||||
p.points_teta = vec![
|
||||
0.0,
|
||||
2.0 * 1.0 * PI / 42.0,
|
||||
2.0 * 5.0 * PI / 42.0,
|
||||
2.0 * 13.0 * PI / 42.0,
|
||||
2.0 * 18.0 * PI / 42.0,
|
||||
2.0 * 19.0 * PI / 42.0,
|
||||
2.0 * 24.0 * PI / 42.0,
|
||||
2.0 * 29.0 * PI / 42.0,
|
||||
2.0 * 30.0 * PI / 42.0,
|
||||
2.0 * 41.0 * PI / 42.0,
|
||||
];
|
||||
p
|
||||
}
|
||||
}
|
||||
fn dummy_sound() -> StaticSoundData {
|
||||
|
||||
Reference in New Issue
Block a user