add small canvas on time line
This commit is contained in:
@@ -2,12 +2,12 @@ use crate::utils::string_to_color;
|
||||
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use iced::Size;
|
||||
use iced::Vector;
|
||||
use iced::mouse;
|
||||
use iced::widget::canvas;
|
||||
use iced::widget::canvas::Stroke;
|
||||
use iced::widget::canvas::Style;
|
||||
use iced::{Color, Rectangle, Renderer, Theme};
|
||||
use iced::widget::canvas::{Frame, Stroke, Style};
|
||||
use iced::{Color, Point, Rectangle, Renderer, Theme};
|
||||
use kira::sound::static_sound::StaticSoundData;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -49,6 +49,65 @@ impl PolygonFrame {
|
||||
polygons: vec![],
|
||||
}
|
||||
}
|
||||
pub fn draw_in_frame(&self, frame: &mut Frame, size: Size) {
|
||||
let radius = size.height / 2.0 - (size.height / 10.);
|
||||
let mut vec = Vector::new(0.0, -radius);
|
||||
let c = Point {
|
||||
x: size.width / 2.,
|
||||
y: size.height / 2.,
|
||||
};
|
||||
|
||||
// Draw Circle
|
||||
let circle = canvas::Path::circle(c, radius);
|
||||
frame.stroke(
|
||||
&circle,
|
||||
Stroke {
|
||||
width: 6.0,
|
||||
style: Style::Solid(Color::from_rgba8(210, 193, 182, 0.25)),
|
||||
..Stroke::default()
|
||||
},
|
||||
);
|
||||
|
||||
// Draw all polygons by there points
|
||||
for poly in &self.polygons {
|
||||
let l = poly.points_teta.len();
|
||||
let mut line: canvas::Path;
|
||||
let mut t1: f32;
|
||||
let mut t2: f32;
|
||||
let mut color: Color;
|
||||
for i in 0..l {
|
||||
t1 = poly.points_teta[i] + poly.global_teta;
|
||||
t2 = poly.points_teta[(i + 1) % l] + poly.global_teta;
|
||||
line = canvas::Path::line(c + vec.rotate(t1), c + vec.rotate(t2));
|
||||
color = poly.color.clone();
|
||||
color.a = 0.25;
|
||||
frame.stroke(
|
||||
&line,
|
||||
Stroke {
|
||||
width: 4.0,
|
||||
style: Style::Solid(poly.color.clone()),
|
||||
..Stroke::default()
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
/*
|
||||
// Draw the red dot on the current position
|
||||
let dot = canvas::Path::circle(frame.center() + vec.rotate(self.teta), 10.0);
|
||||
frame.fill(&dot, Color::from_rgb(1.0, 0.0, 0.0));
|
||||
*/
|
||||
// Draw the frame
|
||||
/*
|
||||
frame.stroke_rectangle(
|
||||
iced::Point { x: 0.0, y: 0.0 },
|
||||
size,
|
||||
Stroke {
|
||||
width: 8.0,
|
||||
style: Style::Solid(Color::from_rgb8(207, 74, 28)),
|
||||
..Stroke::default()
|
||||
},
|
||||
);*/
|
||||
}
|
||||
}
|
||||
|
||||
impl<Message> canvas::Program<Message> for PolygonFrame {
|
||||
|
||||
Reference in New Issue
Block a user