add color picker and better buttons

This commit is contained in:
2025-07-10 15:07:52 +02:00
parent a7e2063b5a
commit d7ca838708
7 changed files with 314 additions and 241 deletions

View File

@@ -2,6 +2,7 @@
name = "polygomusic"
version = "0.1.0"
edition = "2024"
build = "build.rs"
[dependencies]
iced = { version = "0.13.1", features = ["canvas", "tokio"] }

39
build.rs Normal file
View File

@@ -0,0 +1,39 @@
use std::env;
use std::fs;
use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=assets");
println!("cargo:rerun-if-changed=fonts");
// Chemin vers target/debug ou target/release
let out_dir = env::var("OUT_DIR").unwrap();
let target_dir = Path::new(&out_dir)
.ancestors()
.nth(3) // On remonte pour arriver dans target/debug ou target/release
.unwrap();
// Copie assets/
let _ = fs::remove_dir_all(target_dir.join("assets"));
fs::create_dir_all(target_dir.join("assets")).unwrap();
copy_dir("assets", target_dir.join("assets"));
// Copie fonts/
let _ = fs::remove_dir_all(target_dir.join("fonts"));
fs::create_dir_all(target_dir.join("fonts")).unwrap();
copy_dir("fonts", target_dir.join("fonts"));
}
fn copy_dir(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
for entry in fs::read_dir(src).unwrap() {
let entry = entry.unwrap();
let ty = entry.file_type().unwrap();
let dst_path = dst.as_ref().join(entry.file_name());
if ty.is_dir() {
fs::create_dir_all(&dst_path).unwrap();
copy_dir(entry.path(), &dst_path);
} else {
fs::copy(entry.path(), &dst_path).unwrap();
}
}
}

View File

@@ -13,11 +13,12 @@ use utils::{is_delta_format_valid, str_to_sec};
use std::fs;
use iced::widget::{TextInput, column, text};
use iced::{Application, Element, Font, font};
use iced::{Application, Element, Font, Subscription, font};
use iced::{
Color, Length, Task, Theme,
widget::{Column, button, canvas, container, pick_list, row, scrollable, slider},
};
use iced_aw::widget::{ColorPicker, color_picker};
use std::f32::consts::PI;
use std::time::Instant;
@@ -50,6 +51,7 @@ fn main() -> iced::Result {
};
iced::application("My App", MyApp::update, MyApp::view)
.theme(move |_| polytheme.clone())
.font(iced_fonts::REQUIRED_FONT_BYTES)
.font(FONT_BYTES)
.default_font(FONT)
.antialiasing(true)
@@ -119,14 +121,12 @@ impl MyApp {
}
}
Message::Remove(i) => {
self.music.remove_polygon(self.current_delta, i - 1);
self.music.remove_polygon(self.current_delta, i);
}
Message::ChangeTeta(i, teta) => {
self.music.set_teta(self.current_delta, i, teta);
}
Message::ChangeColor(i, s) => {
self.music.set_color(self.current_delta, i, s);
}
Message::ChangeSound(i, s) => {
let sound = StaticSoundData::from_file(format!("./assets/{s}"))
.expect("Fail to load audio");
@@ -199,16 +199,52 @@ impl MyApp {
self.music.fix_teta(self.current_delta);
self.update_canvas_if_paused();
}
Message::ChangeDegree(i, s) => {
let mut mut_s = s;
if mut_s.len() == 0 {
mut_s = "0".to_string();
}
match mut_s.parse::<f32>() {
Ok(val) => {
if val <= 360. {
self.update(Message::ChangeTeta(i, (val).to_radians()))
}
}
Err(_) => {}
}
}
Message::ChangeNbPerSec(s) => {
let mut_s = s.trim_end_matches(" rev/sec");
if mut_s.len() != s.len() {
match mut_s.parse::<f32>() {
Ok(val) => {
let val = (val * 10.).floor() / 10.;
if val >= 1. {
self.music.nb_sec_for_rev = val
}
}
Err(_) => {}
}
}
}
Message::CancelColor(i) => {
self.music.set_color_picker(self.current_delta, i, false);
self.paused = false;
}
Message::SubmitColor(i) => {
if !self.paused {
self.update(Message::TogglePaused);
}
self.music.set_color_picker(self.current_delta, i, true);
}
Message::ChooseColor(i, color) => {
self.music.set_color(self.current_delta, i, color);
self.music.set_color_picker(self.current_delta, i, false);
}
}
}
fn view(&self) -> iced::Element<Message> {
let txt_nb_rev = if self.music.nb_sec_for_rev % 1. != 0.0 {
format!("{} sec/revolution", self.music.nb_sec_for_rev)
} else {
format!("{}.0 sec/revolution", self.music.nb_sec_for_rev)
};
let mut i = 0;
let entries = self.all_sounds.clone();
//Create all polygon options
@@ -219,30 +255,44 @@ impl MyApp {
.iter()
.map(|polygon| {
let current_index = i;
i += 1;
column![
let but = button(text("").size(20).center()).on_press(Message::SubmitColor(i));
let c = column![
row![
text(&polygon.name).font(FONT),
button("Remove").on_press(Message::Remove(i)),
pick_list(
["Black", "Blue", "Green", "Pink", "Yellow", "Cyan"]
.map(|s| s.to_string())
.to_vec(),
Some(&polygon.color_name),
move |s| { Message::ChangeColor(current_index, s) }
text(&polygon.name).size(24),
button(text("").size(20)).on_press(Message::Remove(i)),
color_picker(
polygon.show_color_picker,
polygon.color,
but,
Message::CancelColor(i),
move |color| Message::ChooseColor(i, color)
),
pick_list(entries.clone(), Some(&polygon.sound_name), move |s| {
Message::ChangeSound(current_index, s)
}),
})
.text_size(20),
]
.spacing(20),
slider(0.0..=2.0 * PI, polygon.global_teta, move |f| {
Message::ChangeTeta(current_index, f)
})
.step(PI / 84f32), // 84 | 4 for do PI / 4
row![
TextInput::new("90", &polygon.global_teta.to_degrees().floor().to_string())
.on_input(move |new_value| Message::ChangeDegree(
current_index,
new_value
))
.width(Length::FillPortion(1)),
slider(0.0..=2.0 * PI, polygon.global_teta, move |f| {
Message::ChangeTeta(current_index, f)
})
.step(PI / 84f32) // 84 | 4 for do PI / 4
.width(Length::FillPortion(9))
.height(32),
]
.spacing(10),
]
.spacing(10)
.into()
.into();
i += 1;
c
})
.collect();
let ngon_options: Vec<String> = (5..=42).map(|sides| format!("Ngon{sides}")).collect();
@@ -292,12 +342,6 @@ impl MyApp {
column![
text("Polymusic").size(32.0),
row(save_panel).spacing(20),
row![
text(txt_nb_rev).size(20),
button("Increment").on_press(Message::ButtonPressedIncrement),
button("Decrement").on_press(Message::ButtonPressedDecrement),
]
.spacing(20),
row![
container(
canvas(self.music.current_frame(self.current_delta))
@@ -305,10 +349,11 @@ impl MyApp {
.width(Length::FillPortion(1))
),
column![
text("Polygon options"),
text("Polygon options").size(26),
pick_list(all_options, Some("Choose polygon".to_string()), |s| {
Message::AddPolygon(s)
}),
})
.text_size(18),
polygon_column,
]
.spacing(10)
@@ -319,19 +364,35 @@ impl MyApp {
.spacing(20),
column![
row![
button(text(if self.paused { "󰐊" } else { "󰏤" }).size(28))
.on_press(Message::TogglePaused),
TextInput::new("MM:SS:CS", &self.str_time)
.on_input(|new_value| Message::ChangeDeltaString(new_value))
.size(28),
text("/").size(30),
TextInput::new("MM:SS:CS", &self.str_music_length)
.on_input(|new_value| Message::LengthChange(new_value))
.size(28),
button(text("").size(28)).on_press(Message::AddPoint),
button(text("").size(28)).on_press(Message::RemovePoint),
button(text("").size(28)).on_press(Message::SlidePointLeft),
button(text("").size(28)).on_press(Message::SlidePointRight),
button(text(if self.paused { "󰐊" } else { "󰏤" }).size(28).center())
.on_press(Message::TogglePaused)
.width(Length::FillPortion(1)),
row![
TextInput::new("MM:SS:CS", &self.str_time)
.on_input(|new_value| Message::ChangeDeltaString(new_value))
.size(28),
text("/").size(30),
TextInput::new("MM:SS:CS", &self.str_music_length)
.on_input(|new_value| Message::LengthChange(new_value))
.size(28),
]
.width(Length::FillPortion(10)),
TextInput::new("1.0", &format!("{:.1} rev/sec", &self.music.nb_sec_for_rev))
.on_input(|new_value| Message::ChangeNbPerSec(new_value))
.size(28)
.width(Length::FillPortion(2)),
button(text("").size(28).center())
.on_press(Message::SlidePointLeft)
.width(Length::FillPortion(1)),
button(text("").size(28).center())
.on_press(Message::AddPoint)
.width(Length::FillPortion(1)),
button(text("").size(28).center())
.on_press(Message::SlidePointRight)
.width(Length::FillPortion(1)),
button(text("").size(28).center())
.on_press(Message::RemovePoint)
.width(Length::FillPortion(1)),
]
.spacing(20),
column![
@@ -356,10 +417,11 @@ impl MyApp {
}
fn subscription(&self) -> iced::Subscription<Message> {
iced::Subscription::batch([
//window::events().map(|(_id, event)| Message::WindowEvent(event)),
iced::time::every(std::time::Duration::from_millis(16)).map(|_| Message::Tick),
])
if self.paused {
Subscription::none() // ➝ désactive toutes les subscriptions
} else {
iced::time::every(std::time::Duration::from_millis(16)).map(|_| Message::Tick)
}
}
fn update_canvas_if_paused(&mut self) {

View File

@@ -1,12 +1,14 @@
use iced::Color;
#[derive(Debug, Clone)]
pub enum Message {
ButtonPressedIncrement,
ButtonPressedDecrement,
ChangeNbPerSec(String),
Tick,
AddPolygon(String),
ChangeTeta(usize, f32),
Remove(usize),
ChangeColor(usize, String),
ChangeSound(usize, String),
ToggleSavePanel,
Save,
@@ -21,4 +23,9 @@ pub enum Message {
ChangeDeltaString(String),
SlidePointLeft,
SlidePointRight,
ChangeDegree(usize, String),
ChooseColor(usize, Color),
CancelColor(usize),
SubmitColor(usize),
}

View File

@@ -17,6 +17,7 @@ use iced::widget::canvas;
use iced::widget::canvas::Stroke;
use iced::widget::canvas::Style;
use iced::{Color, Rectangle, Renderer, Theme};
use std::env::current_dir;
use std::f32::consts::PI;
use std::mem::swap;
use std::time::Duration;
@@ -125,10 +126,14 @@ impl Music {
self.find_poly_frame(delta).polygons[index].global_teta = teta;
}
pub fn set_color(&mut self, delta: f32, index: usize, color_name: String) {
pub fn set_color(&mut self, delta: f32, index: usize, color: Color) {
let current_frame = self.find_poly_frame(delta);
current_frame.polygons[index].color = string_to_color(&color_name);
current_frame.polygons[index].color_name = color_name;
current_frame.polygons[index].color = color;
}
pub fn set_color_picker(&mut self, delta: f32, i: usize, b: bool) {
let current_frame = self.find_poly_frame(delta);
current_frame.polygons[i].show_color_picker = b;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ADD/REMOVE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

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

View File

@@ -49,46 +49,46 @@ pub fn string_to_polygon<S: AsRef<str>>(str: S) -> Polygon {
let mut poly: Polygon;
if s.starts_with("Ngon") {
if let Ok(sides) = s.trim_start_matches("Ngon").parse::<u8>() {
poly = Polygon::n_gon(0.0, sides, dummy_sound());
poly = Polygon::n_gon(sides, dummy_sound());
} else {
poly = Polygon::n_gon(0.0, 0, dummy_sound());
poly = Polygon::n_gon(0, dummy_sound());
}
} else {
match s {
"Segment" => {
poly = Polygon::segment(0.0, dummy_sound());
poly = Polygon::segment(dummy_sound());
}
"Triangle" => {
poly = Polygon::triangle(0.0, dummy_sound());
poly = Polygon::triangle(dummy_sound());
}
"Square" => {
poly = Polygon::square(0.0, dummy_sound());
poly = Polygon::square(dummy_sound());
}
"Nr6In30" => {
poly = Polygon::nr_6_in_30(0.0, dummy_sound());
poly = Polygon::nr_6_in_30(dummy_sound());
}
"Nr7In30" => {
poly = Polygon::nr_7_in_30(0.0, dummy_sound());
poly = Polygon::nr_7_in_30(dummy_sound());
}
"Nr8In30" => {
poly = Polygon::nr_8_in_30(0.0, dummy_sound());
poly = Polygon::nr_8_in_30(dummy_sound());
}
"Nr9In30" => {
poly = Polygon::nr_9_in_30(0.0, dummy_sound());
poly = Polygon::nr_9_in_30(dummy_sound());
}
"Nr8In42" => {
poly = Polygon::nr_8_in_42(0.0, dummy_sound());
poly = Polygon::nr_8_in_42(dummy_sound());
}
"Nr9In42" => {
poly = Polygon::nr_9_in_42(0.0, dummy_sound());
poly = Polygon::nr_9_in_42(dummy_sound());
}
"Nr10aIn42" => {
poly = Polygon::nr_10a_in_42(0.0, dummy_sound());
poly = Polygon::nr_10a_in_42(dummy_sound());
}
"Nr10bIn42" => {
poly = Polygon::nr_10b_in_42(0.0, dummy_sound());
poly = Polygon::nr_10b_in_42(dummy_sound());
}
_ => poly = Polygon::n_gon(0.0, 0, dummy_sound()),
_ => poly = Polygon::n_gon(0, dummy_sound()),
}
}
poly.name = s.to_string();