add ngon and change sound on polygon
This commit is contained in:
@@ -6,11 +6,7 @@ use iced::widget::canvas;
|
||||
use iced::widget::canvas::Stroke;
|
||||
use iced::widget::canvas::Style;
|
||||
use iced::{Color, Rectangle, Renderer, Theme};
|
||||
use kira::PlaySoundError;
|
||||
use kira::{
|
||||
AudioManager, AudioManagerSettings, DefaultBackend, sound::static_sound::StaticSoundData,
|
||||
};
|
||||
use std::time::Instant;
|
||||
use kira::sound::static_sound::StaticSoundData;
|
||||
|
||||
pub trait RotationExt {
|
||||
fn rotate(&mut self, teta: f32) -> Self;
|
||||
@@ -55,6 +51,16 @@ impl<Message> canvas::Program<Message> for PolygonFrame {
|
||||
let radius = frame.size().width / 2.0 - 32.0;
|
||||
let mut vec = Vector::new(0.0, -radius);
|
||||
let c = frame.center();
|
||||
// Draw Circle
|
||||
let circle = canvas::Path::circle(frame.center(), radius);
|
||||
frame.stroke(
|
||||
&circle,
|
||||
Stroke {
|
||||
width: 6.0,
|
||||
style: Style::Solid(Color::from_rgba(0.0, 0.0, 0.0, 1.0)),
|
||||
..Stroke::default()
|
||||
},
|
||||
);
|
||||
|
||||
// Draw all polygons by there points
|
||||
for poly in &self.polygons {
|
||||
@@ -77,16 +83,6 @@ impl<Message> canvas::Program<Message> for PolygonFrame {
|
||||
}
|
||||
}
|
||||
|
||||
// Draw Circle
|
||||
let circle = canvas::Path::circle(frame.center(), radius);
|
||||
frame.stroke(
|
||||
&circle,
|
||||
Stroke {
|
||||
width: 6.0,
|
||||
style: Style::Solid(Color::from_rgba(0.0, 0.0, 0.0, 1.0)),
|
||||
..Stroke::default()
|
||||
},
|
||||
);
|
||||
// Draw the red dot on the current position
|
||||
let dot = canvas::Path::circle(frame.center() + vec.rotate(self.teta), 5.0);
|
||||
frame.fill(&dot, Color::from_rgb(1.0, 0.0, 0.0));
|
||||
|
||||
Reference in New Issue
Block a user