Add From impls for Length, Point, and Size
This commit is contained in:
parent
811d8b90d7
commit
62725a76ef
3 changed files with 30 additions and 0 deletions
|
|
@ -27,3 +27,9 @@ impl Length {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<u16> for Length {
|
||||||
|
fn from(units: u16) -> Self {
|
||||||
|
Length::Units(units)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,18 @@ impl Point {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<[f32; 2]> for Point {
|
||||||
|
fn from([x, y]: [f32; 2]) -> Self {
|
||||||
|
Point { x, y }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<[u16; 2]> for Point {
|
||||||
|
fn from([x, y]: [u16; 2]) -> Self {
|
||||||
|
Point::new(x.into(), y.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl std::ops::Add<Vector> for Point {
|
impl std::ops::Add<Vector> for Point {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,3 +37,15 @@ impl Size {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<[f32; 2]> for Size {
|
||||||
|
fn from([width, height]: [f32; 2]) -> Self {
|
||||||
|
Size { width, height }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<[u16; 2]> for Size {
|
||||||
|
fn from([width, height]: [u16; 2]) -> Self {
|
||||||
|
Size::new(width.into(), height.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue