1use iced_core::Point;
4
5#[derive(Copy, Clone, Debug)]
7pub struct Offset {
8 pub x: f32,
10 pub y: f32,
12}
13
14impl Offset {
15 #[must_use]
17 pub fn new(x: f32, y: f32) -> Self {
18 Self { x, y }
19 }
20}
21
22impl From<f32> for Offset {
23 fn from(float: f32) -> Self {
24 Self { x: float, y: float }
25 }
26}
27
28impl From<[f32; 2]> for Offset {
29 fn from(array: [f32; 2]) -> Self {
30 Self {
31 x: array[0],
32 y: array[1],
33 }
34 }
35}
36
37impl From<Offset> for Point {
38 fn from(offset: Offset) -> Self {
39 Self::new(offset.x, offset.y)
40 }
41}
42
43impl From<&Offset> for Point {
44 fn from(offset: &Offset) -> Self {
45 Self::new(offset.x, offset.y)
46 }
47}