bms_rs/bms/command/
graphics.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub struct PixelPoint {
7 pub x: i16,
9 pub y: i16,
11}
12
13impl PixelPoint {
14 #[must_use]
16 pub const fn new(x: i16, y: i16) -> Self {
17 Self { x, y }
18 }
19}
20
21impl From<(i16, i16)> for PixelPoint {
22 fn from((x, y): (i16, i16)) -> Self {
23 Self { x, y }
24 }
25}
26
27impl From<PixelPoint> for (i16, i16) {
28 fn from(point: PixelPoint) -> Self {
29 (point.x, point.y)
30 }
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
35#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
36pub struct PixelSize {
37 pub width: u16,
39 pub height: u16,
41}
42
43impl PixelSize {
44 #[must_use]
46 pub const fn new(width: u16, height: u16) -> Self {
47 Self { width, height }
48 }
49}
50
51impl From<(u16, u16)> for PixelSize {
52 fn from((width, height): (u16, u16)) -> Self {
53 Self { width, height }
54 }
55}
56
57impl From<PixelSize> for (u16, u16) {
58 fn from(size: PixelSize) -> Self {
59 (size.width, size.height)
60 }
61}
62
63#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
65#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
66pub struct Argb {
67 pub alpha: u8,
69 pub red: u8,
71 pub green: u8,
73 pub blue: u8,
75}
76
77impl Default for Argb {
78 fn default() -> Self {
79 Self {
80 alpha: 255,
81 red: 0,
82 green: 0,
83 blue: 0,
84 }
85 }
86}
87
88#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
90#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
91pub struct Rgb {
92 pub r: u8,
94 pub g: u8,
96 pub b: u8,
98}