Remove Color::From<u32>

Instead make it clear on the call site what the encoding is (argb).
This commit is contained in:
Simon Hausmann 2020-09-03 11:17:40 +02:00
parent adec90e8d2
commit 3b971a2e2f
3 changed files with 2 additions and 8 deletions

View file

@ -685,7 +685,7 @@ fn compile_expression(e: &Expression, component: &Rc<Component>) -> TokenStream
(Type::Float32, Type::Model) | (Type::Int32, Type::Model) => quote!((0..#f as i32)),
(Type::Array(_), Type::Model) => quote!(#f.iter().cloned()),
(Type::Float32, Type::Color) => {
quote!(sixtyfps::re_exports::Color::from(#f as u32))
quote!(sixtyfps::re_exports::Color::from_argb_encoded(#f as u32))
}
_ => f,
}

View file

@ -104,12 +104,6 @@ impl Color {
pub const TRANSPARENT: Color = Color::from_rgba(0, 0, 0, 0);
}
impl From<u32> for Color {
fn from(encoded: u32) -> Self {
Color::from_argb_encoded(encoded)
}
}
impl InterpolatedPropertyValue for Color {
fn interpolate(self, target_value: Self, t: f32) -> Self {
Self {

View file

@ -209,7 +209,7 @@ pub fn eval_expression(
(Value::Number(n), Type::String) => {
Value::String(SharedString::from(format!("{}", n).as_str()))
}
(Value::Number(n), Type::Color) => Value::Color(Color::from(n as u32)),
(Value::Number(n), Type::Color) => Value::Color(Color::from_argb_encoded(n as u32)),
(v, _) => v,
}
}