You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let color = Self::from_rgba_u32(rgb << 8 | a asu32);
86
+
Some(color)
87
+
}else{
88
+
None
89
+
}
90
+
}
91
+
92
+
/// Construct a color from a single `u32` value, in `RGBA` format.
93
+
///
94
+
/// Example:
95
+
/// ```
96
+
/// use gdnative::prelude::Color;
97
+
///
98
+
/// // RGBA (178, 217, 10, 158)
99
+
/// let one = Color::from_rgba_u32(0xb2d90a9e);
100
+
/// let piecewise = Color::from_rgba_u8(0xB2, 0xD9, 0x0A, 0x9E);
101
+
/// assert_eq!(one, piecewise);
102
+
/// ```
103
+
#[inline]
104
+
pubfnfrom_rgba_u32(rgba:u32) -> Self{
105
+
Self::from_rgba_u8(
106
+
(rgba >> 24)asu8,
107
+
((rgba >> 16)&0xFF)asu8,
108
+
((rgba >> 8)&0xFF)asu8,
109
+
(rgba &0xFF)asu8,
110
+
)
111
+
}
112
+
113
+
/// Constructs a color from four integer channels, each in range 0-255.
114
+
///
115
+
/// This corresponds to the [GDScript method `Color8`](https://docs.godotengine.org/en/stable/classes/class_%40gdscript.html#class-gdscript-method-color8)
0 commit comments