2023-06-29 21:24:56 +00:00
|
|
|
#[derive(Debug,Clone,Copy,Default)]
|
2023-06-04 19:31:32 +00:00
|
|
|
pub struct Point {
|
|
|
|
pub x: f32,
|
|
|
|
pub y: f32,
|
|
|
|
pub color: Color
|
|
|
|
}
|
|
|
|
|
2023-06-29 21:24:56 +00:00
|
|
|
#[derive(Debug,Clone,Copy,Default)]
|
2023-06-04 19:31:32 +00:00
|
|
|
pub struct Color {
|
|
|
|
r: u8,
|
|
|
|
g: u8,
|
|
|
|
b: u8
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<(f32,f32,u32)> for Point {
|
|
|
|
fn from((x, y, color) : (f32, f32, u32)) -> Point {
|
|
|
|
let r = (color >> 16) as u8 ;
|
|
|
|
let g = ((color >> 8) & 255) as u8 ;
|
|
|
|
let b = (color & 255) as u8 ;
|
|
|
|
Point { x, y, color: Color { r, g, b } }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Point> for helios_dac::Point {
|
|
|
|
fn from(pt: Point) -> helios_dac::Point {
|
|
|
|
let x = pt.x.clamp(0.0, 4095.0) as u16;
|
|
|
|
let y = pt.y.clamp(0.0, 4095.0) as u16;
|
|
|
|
helios_dac::Point {
|
|
|
|
coordinate: (x, y).into(),
|
|
|
|
color: helios_dac::Color::new(pt.color.r, pt.color.g, pt.color.b),
|
|
|
|
intensity: 0xFF
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|