outfly/src/common.rs

56 lines
2 KiB
Rust
Raw Normal View History

2024-05-12 22:44:03 +00:00
// ▄████████▄ + ███ + ▄█████████ ███ +
// ███▀ ▀███ + + ███ ███▀ + ███ + +
// ███ + ███ ███ ███ █████████ ███ ███ ███ ███
// ███ +███ ███ ███ ███ ███▐██████ ███ ███ ███
// ███ + ███ ███+ ███ +███ ███ + ███ ███ + ███
// ███▄ ▄███ ███▄ ███ ███ + ███ + ███ ███▄ ███
// ▀████████▀ + ▀███████ ███▄ ███▄ ▀████ ▀███████
// + + + ███
// + ▀████████████████████████████████████████████████████▀
//
2024-05-12 22:48:41 +00:00
// Various common functions and constants
2024-05-12 22:44:03 +00:00
use bevy::prelude::*;
pub use bevy::math::{DVec3, DQuat};
2024-05-12 23:00:09 +00:00
pub use std::f32::consts::PI as PI32;
pub use std::f64::consts::PI;
pub const WINDOW_TITLE: &str = "OutFly";
pub const FONT: &str = "fonts/Yupiter-Regular.ttf";
2024-05-12 22:48:41 +00:00
pub const EPSILON32: f32 = 1e-9;
pub const EPSILON: f64 = 1e-9;
2024-05-12 22:44:03 +00:00
#[inline]
2024-05-12 23:00:09 +00:00
pub fn bool2vis(boolean: bool) -> Visibility {
2024-05-12 22:44:03 +00:00
if boolean {
2024-05-12 23:00:09 +00:00
Visibility::Inherited
2024-05-12 22:44:03 +00:00
} else {
2024-05-12 23:00:09 +00:00
Visibility::Hidden
2024-05-12 22:44:03 +00:00
}
}
#[inline]
pub fn style_fullscreen() -> Style {
Style {
width: Val::Vw(100.0),
height: Val::Vh(100.0),
position_type: PositionType::Absolute,
top: Val::Px(0.0),
left: Val::Px(0.0),
..default()
}
}
#[inline]
pub fn style_centered() -> Style {
Style {
width: Val::Percent(100.0),
height: Val::Percent(100.0),
align_items: AlignItems::Center,
justify_content: JustifyContent::SpaceAround,
..default()
}
}