assimp/math/
color4.rs
1#[cfg(feature = "cgmath")]
2use cgmath::Vector4;
3use ffi::AiColor4D;
4
5define_type_and_iterator! {
6 #[derive(Clone, Copy, Debug, PartialEq)]
8 struct Color4D(AiColor4D)
9 struct Color4DIter
11}
12
13impl Color4D {
14 pub fn new(r: f32, g: f32, b: f32, a: f32) -> Color4D {
15 Color4D(AiColor4D { r: r, g: g, b: b, a: a })
16 }
17}
18
19impl From<[f32; 4]> for Color4D {
20 fn from(v: [f32; 4]) -> Color4D {
21 Color4D::new(v[0], v[1], v[2], v[3])
22 }
23}
24
25impl From<Color4D> for [f32; 4] {
26 fn from(c: Color4D) -> [f32; 4] {
27 [c.r, c.g, c.b, c.a]
28 }
29}
30
31#[cfg(feature = "cgmath")]
32impl From<Vector4<f32>> for Color4D {
33 fn from(v: Vector4<f32>) -> Color4D {
34 Color4D::new(v[0], v[1], v[2], v[3])
35 }
36}
37
38#[cfg(feature = "cgmath")]
39impl From<Color4D> for Vector4<f32> {
40 fn from(c: Color4D) -> Vector4<f32> {
41 Vector4::new(c.r, c.g, c.b, c.a)
42 }
43}