Skip to main content

flake/misc/
mod.rs

1use crate::prelude::{Quaternion, Rect, Span, Timer, Vector2, Vector3, Vector4};
2
3pub mod math;
4pub mod rect;
5pub mod font;
6pub mod timer;
7pub mod span;
8pub mod flake_image;
9
10macro_rules! simplified_constructors {
11    ($($name:ident $(<$lt:lifetime>)? ($($arg:ident: $ty:ty),*) -> $ret:ty => $new:path;)*) => {
12        $(
13            #[inline]
14            pub fn $name $(<$lt>)? ($($arg: $ty),*) -> $ret {
15                $new($($arg),*)
16            }
17        )*
18    };
19}
20
21simplified_constructors! {
22    vec2(x: f32, y: f32) -> Vector2 => Vector2::new;
23    vec3(x: f32, y: f32, z: f32) -> Vector3 => Vector3::new;
24    vec4(x: f32, y: f32, z: f32, w: f32) -> Vector4 => Vector4::new;
25    quat(x: f32, y: f32, z: f32, w: f32) -> Quaternion => Quaternion::new;
26
27    rect(x: f32, y: f32, w: f32, h: f32) -> Rect => Rect::new;
28
29    timer(seconds: f32) -> Timer => Timer::new;
30    timer_repeating(seconds: f32) -> Timer => Timer::new_repeating;
31
32    span<'a>(text: &'a str) -> Span<'a> => Span::new;
33}