mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -04:00
Add Vec2::to_pos2
This commit is contained in:
@@ -133,6 +133,13 @@ impl Vec2 {
|
|||||||
Self { x: v, y: v }
|
Self { x: v, y: v }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Treat this vector as a position.
|
||||||
|
/// `v.to_pos2()` is equivalent to `Pos2::default() + v`.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn to_pos2(self) -> crate::Pos2 {
|
||||||
|
crate::Pos2::new(self.x, self.y)
|
||||||
|
}
|
||||||
|
|
||||||
/// Safe normalize: returns zero if input is zero.
|
/// Safe normalize: returns zero if input is zero.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|||||||
Reference in New Issue
Block a user