outfly/src/common.rs

53 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 22:52:34 +00:00
pub use std::f32::consts::PI as PI32;
pub use std::f64::consts::PI;
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]
pub fn bool2vis(boolean: bool) -> bevy::prelude::Visibility {
if boolean {
bevy::prelude::Visibility::Inherited
} else {
bevy::prelude::Visibility::Hidden
}
}
#[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()
}
}