#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Alignment {
BottomLeft = 1,
BottomCenter = 2,
BottomRight = 3,
MiddleLeft = 4,
Center = 5,
MiddleRight = 6,
TopLeft = 7,
TopCenter = 8,
TopRight = 9,
}
impl Alignment {
pub fn from_value(value: u8) -> Self {
match value {
1 => Self::BottomLeft,
2 => Self::BottomCenter,
3 => Self::BottomRight,
4 => Self::MiddleLeft,
5 => Self::Center,
6 => Self::MiddleRight,
7 => Self::TopLeft,
8 => Self::TopCenter,
9 => Self::TopRight,
_ => Self::BottomCenter, }
}
pub fn from_ssa_legacy(value: u8) -> Self {
match value & 3 {
1 => {
match value & 12 {
0 => Self::BottomLeft,
4 => Self::MiddleLeft,
8 | 12 => Self::TopLeft,
_ => Self::BottomLeft,
}
}
2 => {
match value & 12 {
0 => Self::BottomCenter,
4 => Self::Center,
8 | 12 => Self::TopCenter,
_ => Self::BottomCenter,
}
}
3 => {
match value & 12 {
0 => Self::BottomRight,
4 => Self::MiddleRight,
8 | 12 => Self::TopRight,
_ => Self::BottomRight,
}
}
_ => Self::BottomCenter,
}
}
}