Add conversion functions to Size and Vector
This commit is contained in:
parent
d3b04bf892
commit
9090fa6a22
2 changed files with 33 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use super::vector::Vector;
|
||||
use std::f32;
|
||||
|
||||
/// An amount of space in 2 dimensions.
|
||||
|
|
@ -57,6 +58,15 @@ impl From<[u16; 2]> for Size {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Vector<f32>> for Size {
|
||||
fn from(vector: Vector<f32>) -> Self {
|
||||
Size {
|
||||
width: vector.x,
|
||||
height: vector.y,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Size> for [f32; 2] {
|
||||
fn from(size: Size) -> [f32; 2] {
|
||||
[size.width, size.height]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue