#[derive(Debug, Clone, Copy)]
pub struct RouteScale {
pub scale: f64,
pub offset_x_percent: f64,
pub offset_y_percent: f64,
}
impl RouteScale {
pub fn new(scale: f64, offset_x_percent: f64, offset_y_percent: f64) -> Self {
Self {
scale,
offset_x_percent,
offset_y_percent,
}
}
pub fn centered() -> Self {
Self {
scale: 0.4,
offset_x_percent: 0.3,
offset_y_percent: 0.3,
}
}
pub fn large() -> Self {
Self {
scale: 0.7,
offset_x_percent: 0.15,
offset_y_percent: 0.15,
}
}
}
impl Default for RouteScale {
fn default() -> Self {
Self {
scale: 0.2,
offset_x_percent: 0.1,
offset_y_percent: 0.1,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct RouteColor {
pub route_line: [f64; 4],
pub current_position: [f64; 4],
pub text: [f64; 4],
pub lap_bars: [f64; 4],
}
impl RouteColor {
pub fn new(
route_line: [f64; 4],
current_position: [f64; 4],
text: [f64; 4],
lap_bars: [f64; 4],
) -> Self {
Self {
route_line,
current_position,
text,
lap_bars,
}
}
pub fn blue_scheme() -> Self {
Self {
route_line: [255.0, 0.0, 0.0, 0.0], current_position: [255.0, 255.0, 0.0, 0.0], text: [255.0, 255.0, 255.0, 0.0], lap_bars: [255.0, 128.0, 0.0, 0.0], }
}
pub fn neon_scheme() -> Self {
Self {
route_line: [255.0, 0.0, 255.0, 0.0], current_position: [0.0, 255.0, 255.0, 0.0], text: [255.0, 255.0, 255.0, 0.0], lap_bars: [255.0, 0.0, 255.0, 0.0], }
}
}
impl Default for RouteColor {
fn default() -> Self {
Self {
route_line: [0.0, 0.0, 255.0, 0.0], current_position: [0.0, 255.0, 0.0, 0.0], text: [255.0, 255.0, 255.0, 0.0], lap_bars: [0.0, 255.0, 0.0, 0.0], }
}
}
#[derive(Debug, Clone)]
pub struct FileConfig {
pub fit_file: String,
pub background_image: String,
pub output_file: String,
}
impl FileConfig {
pub fn new(
fit_file: String,
background_image: String,
output_file: String,
) -> Self {
Self {
fit_file,
background_image,
output_file,
}
}
}
impl Default for FileConfig {
fn default() -> Self {
Self {
fit_file: "source/example.fit".to_string(),
background_image: "source/example.jpg".to_string(),
output_file: "outputs/output.mp4".to_string(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum Color {
Black,
White,
Red,
Orange,
Yellow,
YellowGreen,
Green,
BlueGreen,
Blue,
BlueViolet,
Violet,
RedViolet,
RedOrange,
YellowOrange,
}
impl Color {
pub fn to_bgra(&self) -> [f64; 4] {
match self {
Color::Black => [0.0, 0.0, 0.0, 0.0],
Color::White => [255.0, 255.0, 255.0, 0.0],
Color::Red => [0.0, 0.0, 255.0, 0.0],
Color::Orange => [0.0, 165.0, 255.0, 0.0],
Color::Yellow => [0.0, 255.0, 255.0, 0.0],
Color::YellowGreen => [47.0, 255.0, 173.0, 0.0],
Color::Green => [0.0, 255.0, 0.0, 0.0],
Color::BlueGreen => [128.0, 255.0, 0.0, 0.0],
Color::Blue => [255.0, 0.0, 0.0, 0.0],
Color::BlueViolet => [226.0, 43.0, 138.0, 0.0],
Color::Violet => [211.0, 0.0, 148.0, 0.0],
Color::RedViolet => [211.0, 0.0, 199.0, 0.0],
Color::RedOrange => [0.0, 69.0, 255.0, 0.0],
Color::YellowOrange => [0.0, 204.0, 255.0, 0.0],
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum Font {
Simplex,
Plain,
Duplex,
Complex,
Triplex,
ComplexSmall,
ScriptSimplex,
ScriptComplex,
Italic,
}
impl Font {
pub fn to_opencv(&self) -> i32 {
match self {
Font::Simplex => 0, Font::Plain => 1, Font::Duplex => 2, Font::Complex => 3, Font::Triplex => 4, Font::ComplexSmall => 5, Font::ScriptSimplex => 6, Font::ScriptComplex => 7, Font::Italic => 16, }
}
}