Struct glifparser::color::Color

source ·
pub struct Color {
    pub r: IntegerOrFloat,
    pub g: IntegerOrFloat,
    pub b: IntegerOrFloat,
    pub a: IntegerOrFloat,
}

Fields§

§r: IntegerOrFloat§g: IntegerOrFloat§b: IntegerOrFloat§a: IntegerOrFloat

Implementations§

Examples found in repository?
src/color.rs (line 66)
65
66
67
    fn from(c: [f32; 4]) -> Self {
        Color::from_rgba(c[0].into(), c[1].into(), c[2].into(), c[3].into())
    }
Examples found in repository?
src/guideline.rs (line 49)
40
41
42
43
44
45
46
47
48
49
50
51
52
    pub fn as_plist_dict(&self) -> plist::Dictionary {
        let mut dict = plist::Dictionary::new();
        dict.insert("x".to_string(), plist::Value::Real(self.at.x.into()));
        dict.insert("y".to_string(), plist::Value::Real(self.at.y.into()));
        dict.insert("angle".to_string(), plist::Value::Real(self.angle.into()));
        if let Some(ref name) = self.name {
            dict.insert("name".to_string(), plist::Value::String(name.to_string()));
        }
        if let Some(ref color) = self.color {
            dict.insert("color".to_string(), color.as_plist_value());
        }
        dict
    }

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.

This follows the UFO spec, e.g. "0,0,1,1" → blue at 100% opacity

The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
Converts this type into the (usually inferred) input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more

This follows the UFO spec, not other specs that would say to do e.g. rgba(1,1,1,1)

Converts the given value to a String. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.