177 lines
4.5 KiB
Rust
177 lines
4.5 KiB
Rust
use super::{super::Param, Sequence};
|
|
use crate::{
|
|
draw::{draw_line, draw_line_dotted},
|
|
point::{Color, Point},
|
|
};
|
|
|
|
use opencv::Result;
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct WaitSpace {
|
|
borders: [Point; 4],
|
|
red: [Point; 2],
|
|
green: [Point; 2],
|
|
blue: [Point; 2],
|
|
}
|
|
|
|
impl WaitSpace {
|
|
pub fn new(beg: Point, end: Point) -> Self {
|
|
let red_y = (end.y - beg.y) * 1./5. + beg.y;
|
|
let green_y = (end.y - beg.y) * 2./5. + beg.y;
|
|
let blue_y = (end.y - beg.y) * 3./5. + beg.y;
|
|
Self {
|
|
borders: [
|
|
Point {
|
|
x: beg.x,
|
|
y: beg.y,
|
|
color: end.color,
|
|
},
|
|
Point {
|
|
x: end.x,
|
|
y: beg.y,
|
|
color: end.color,
|
|
},
|
|
Point {
|
|
x: end.x,
|
|
y: end.y,
|
|
color: end.color,
|
|
},
|
|
Point {
|
|
x: beg.x,
|
|
y: end.y,
|
|
color: end.color,
|
|
},
|
|
],
|
|
red: [
|
|
Point {
|
|
x: beg.x,
|
|
y: red_y,
|
|
color: end.color,
|
|
},
|
|
Point {
|
|
x: end.x,
|
|
y: red_y,
|
|
color: end.color,
|
|
},
|
|
],
|
|
blue: [
|
|
Point {
|
|
x: beg.x,
|
|
y: blue_y,
|
|
color: end.color,
|
|
},
|
|
Point {
|
|
x: end.x,
|
|
y: blue_y,
|
|
color: end.color,
|
|
},
|
|
],
|
|
green: [
|
|
Point {
|
|
x: beg.x,
|
|
y: green_y,
|
|
color: end.color,
|
|
},
|
|
Point {
|
|
x: end.x,
|
|
y: green_y,
|
|
color: end.color,
|
|
},
|
|
],
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Sequence for WaitSpace {
|
|
fn draw(&self, mem: &Param) -> Option<Vec<Point>> {
|
|
if mem.key == 32 || !mem.capture_mode {
|
|
return None;
|
|
}
|
|
|
|
let mut pl = vec![];
|
|
let color = Color {
|
|
r: mem.r as u8,
|
|
g: mem.g as u8,
|
|
b: mem.b as u8,
|
|
};
|
|
let red = Color {
|
|
r: mem.r as u8,
|
|
g: 0,
|
|
b: 0,
|
|
};
|
|
let green = Color {
|
|
r: 0,
|
|
g: mem.g as u8,
|
|
b: 0,
|
|
};
|
|
let blue = Color {
|
|
r: 0,
|
|
g: 0,
|
|
b: mem.b as u8,
|
|
};
|
|
for i in 0..self.borders.len() {
|
|
let id1 = (i + 1) % self.borders.len();
|
|
let p0 = Point {
|
|
color,
|
|
..self.borders[i]
|
|
};
|
|
let p1 = Point {
|
|
color,
|
|
..self.borders[id1]
|
|
};
|
|
pl.extend(draw_line(
|
|
&p0,
|
|
&p1,
|
|
mem.nb_all as usize,
|
|
mem.nb_visible as usize,
|
|
));
|
|
pl.extend(draw_line_dotted(
|
|
&Point{
|
|
color: blue,
|
|
..self.blue[0]
|
|
},
|
|
&Point{
|
|
color: blue,
|
|
..self.blue[1]
|
|
},
|
|
mem.nb_all as usize,
|
|
mem.nb_visible as usize,
|
|
true,
|
|
));
|
|
pl.extend(draw_line_dotted(
|
|
&Point{
|
|
color: green,
|
|
..self.green[0]
|
|
},
|
|
&Point{
|
|
color: green,
|
|
..self.green[1]
|
|
},
|
|
mem.nb_all as usize,
|
|
mem.nb_visible as usize,
|
|
true,
|
|
));
|
|
pl.extend(draw_line_dotted(
|
|
&Point{
|
|
color: red,
|
|
..self.red[0]
|
|
},
|
|
&Point{
|
|
color: red,
|
|
..self.red[1]
|
|
},
|
|
mem.nb_all as usize,
|
|
mem.nb_visible as usize,
|
|
true,
|
|
));
|
|
}
|
|
Some(pl)
|
|
}
|
|
fn compute_sequence(&mut self, _mem: &mut Param) -> Result<(), Box<dyn std::error::Error>> {
|
|
Ok(())
|
|
}
|
|
fn is_capture(&self) -> bool {
|
|
false
|
|
}
|
|
}
|