Add from_color
to StandardMaterial
and ColorMaterial
(#13791)
# Objective Closes #13738 ## Solution Added `from_color` to materials that would support it. Didn't add `from_color` to `WireframeMaterial` as it doesn't seem we expect users to be constructing them themselves. ## Testing None --- ## Changelog ### Added - `from_color` to `StandardMaterial` so you can construct this material from any color type. - `from_color` to `ColorMaterial` so you can construct this material from any color type.
This commit is contained in:
parent
9a82ecfcba
commit
e14f3ba1aa
@ -747,6 +747,11 @@ impl StandardMaterial {
|
||||
self.flip(horizontal, vertical);
|
||||
self
|
||||
}
|
||||
|
||||
/// Creates a new material from a given color
|
||||
pub fn from_color(color: impl Into<Color>) -> Self {
|
||||
Self::from(color.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for StandardMaterial {
|
||||
|
@ -51,6 +51,13 @@ pub struct ColorMaterial {
|
||||
pub texture: Option<Handle<Image>>,
|
||||
}
|
||||
|
||||
impl ColorMaterial {
|
||||
/// Creates a new material from a given color
|
||||
pub fn from_color(color: impl Into<Color>) -> Self {
|
||||
Self::from(color.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for ColorMaterial {
|
||||
fn default() -> Self {
|
||||
ColorMaterial {
|
||||
|
Loading…
Reference in New Issue
Block a user