1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
2pub struct Size {
3 pub width: usize,
4 pub height: usize,
5}
6
7impl From<(usize, usize)> for Size {
8 fn from((width, height): (usize, usize)) -> Self {
9 Self { width, height }
10 }
11}
12
13impl From<Bounds> for Size {
14 fn from(Bounds { width, height, .. }: Bounds) -> Self {
15 Self { width, height }
16 }
17}
18
19#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
20pub struct Bounds {
21 pub x: usize,
22 pub y: usize,
23 pub width: usize,
24 pub height: usize,
25}
26
27impl From<(usize, usize, usize, usize)> for Bounds {
28 fn from((x, y, width, height): (usize, usize, usize, usize)) -> Self {
29 Self {
30 x,
31 y,
32 width,
33 height,
34 }
35 }
36}
37
38#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
39pub struct Padding {
40 pub top: usize,
41 pub right: usize,
42 pub bottom: usize,
43 pub left: usize,
44}
45
46impl From<usize> for Padding {
47 fn from(padding: usize) -> Self {
48 Self {
49 top: padding,
50 right: padding,
51 bottom: padding,
52 left: padding,
53 }
54 }
55}
56
57impl From<(usize, usize)> for Padding {
58 fn from((vert, horiz): (usize, usize)) -> Self {
59 Self {
60 top: vert,
61 right: horiz,
62 bottom: vert,
63 left: horiz,
64 }
65 }
66}
67
68impl From<(usize, usize, usize, usize)> for Padding {
69 fn from((top, right, bottom, left): (usize, usize, usize, usize)) -> Self {
70 Self {
71 top,
72 right,
73 bottom,
74 left,
75 }
76 }
77}