add audio but better with kira
This commit is contained in:
@@ -6,6 +6,7 @@ use iced::widget::canvas;
|
||||
use iced::widget::canvas::Stroke;
|
||||
use iced::widget::canvas::Style;
|
||||
use iced::{Color, Rectangle, Renderer, Theme};
|
||||
use std::time::Instant;
|
||||
|
||||
pub trait RotationExt {
|
||||
fn rotate(&mut self, teta: f32) -> Self;
|
||||
@@ -24,6 +25,17 @@ pub struct PolygonFrame {
|
||||
pub polygons: Vec<Polygon>,
|
||||
}
|
||||
|
||||
impl PolygonFrame {
|
||||
pub fn have_point_polygon_btw(&self, before: f32, after: f32) -> bool {
|
||||
for poly in &self.polygons {
|
||||
if poly.have_points_btw(before, after) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl<Message> canvas::Program<Message> for PolygonFrame {
|
||||
// No internal state
|
||||
type State = ();
|
||||
@@ -97,6 +109,19 @@ pub struct Polygon {
|
||||
}
|
||||
#[warn(dead_code)]
|
||||
impl Polygon {
|
||||
pub fn have_points_btw(&self, before: f32, after: f32) -> bool {
|
||||
let mut p_g;
|
||||
for p in self.points_teta.clone() {
|
||||
p_g = p + self.global_teta;
|
||||
if before < p_g && p_g < after {
|
||||
return true;
|
||||
}
|
||||
if p_g > after {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
false
|
||||
}
|
||||
pub fn n_gon(teta: f32, n_side: u8) -> Self {
|
||||
let mut v: Vec<f32> = Vec::with_capacity(n_side as usize);
|
||||
for i in 0..n_side {
|
||||
@@ -112,11 +137,11 @@ impl Polygon {
|
||||
}
|
||||
|
||||
pub fn triangle(teta: f32) -> Self {
|
||||
Polygon::n_gon(teta, 2)
|
||||
Polygon::n_gon(teta, 3)
|
||||
}
|
||||
|
||||
pub fn square(teta: f32) -> Self {
|
||||
Polygon::n_gon(teta, 2)
|
||||
Polygon::n_gon(teta, 4)
|
||||
}
|
||||
|
||||
pub fn nr_6_in_30(teta: f32) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user