ailloli_ui_core/geometry/offset.rs
1//! Two-dimensional translation vectors in logical pixels.
2
3/// 2D translation vector in logical pixels.
4///
5/// # Examples
6///
7/// ```
8/// use ailloli_ui_core::Offset;
9/// assert_eq!(Offset::new(2.0, -3.0), Offset { x: 2.0, y: -3.0 });
10/// ```
11#[derive(Debug, Clone, Copy, Default, PartialEq)]
12pub struct Offset {
13 /// Horizontal displacement; positive values point right.
14 pub x: f32,
15 /// Vertical displacement; positive values point down.
16 pub y: f32,
17}
18
19impl Offset {
20 /// Creates an offset `(x, y)` without normalizing non-finite values.
21 ///
22 /// # Examples
23 ///
24 /// ```
25 /// use ailloli_ui_core::Offset;
26 /// assert_eq!(Offset::new(2.0, 3.0).y, 3.0);
27 /// ```
28 pub fn new(x: f32, y: f32) -> Self {
29 Self { x, y }
30 }
31}