re_types/components/
texcoord2d_ext.rs1use crate::datatypes::Vec2D;
2
3use super::Texcoord2D;
4
5impl Texcoord2D {
8 pub const ZERO: Self = Self::new(0.0, 0.0);
10
11 pub const ONE: Self = Self::new(1.0, 1.0);
13
14 #[inline]
16 pub const fn new(u: f32, v: f32) -> Self {
17 Self(Vec2D::new(u, v))
18 }
19
20 #[inline]
22 pub fn u(&self) -> f32 {
23 self.0.x()
24 }
25
26 #[inline]
28 pub fn v(&self) -> f32 {
29 self.0.y()
30 }
31}
32
33#[cfg(feature = "glam")]
34impl From<Texcoord2D> for glam::Vec2 {
35 #[inline]
36 fn from(pt: Texcoord2D) -> Self {
37 Self::new(pt.u(), pt.v())
38 }
39}
40
41#[cfg(feature = "mint")]
42impl From<Texcoord2D> for mint::Point2<f32> {
43 #[inline]
44 fn from(position: Texcoord2D) -> Self {
45 Self {
46 x: position.u(),
47 y: position.v(),
48 }
49 }
50}
51
52#[cfg(feature = "mint")]
53impl From<mint::Point2<f32>> for Texcoord2D {
54 #[inline]
55 fn from(position: mint::Point2<f32>) -> Self {
56 Self(Vec2D([position.x, position.y]))
57 }
58}