FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    HsvColor

    struct · ferroui-base · v0.5.0

    struct HsvColor
    

    Defines a color using the hue/saturation/value (HSV) model. This uses a cylindrical-coordinate representation of a color.

    View source

    Members

    a

    a: f64
    

    The Alpha (transparency) component in the range from 0..1 (percentage). 0 is fully transparent, 1 is fully opaque.

    Source

    h

    h: f64
    

    The Hue component in the range from 0..360 (degrees). This is the color's location, in degrees, on a color wheel/circle from 0 to 360. Note that 360 is equivalent to 0 and will be adjusted automatically.

    Source

    s

    s: f64
    

    The Saturation component in the range from 0..1 (percentage). 0 is a shade of gray (no color) and 1 is the full color.

    Source

    v

    v: f64
    

    The Value component in the range from 0..1 (percentage). 0 is fully black and 1 is the brightest.

    Source

    new

    fn new(alpha: f64, hue: f64, saturation: f64, value: f64) -> Self
    

    Initializes a new instance of the HsvColor struct. Components are clamped to their ranges and a hue of 360 becomes 0.

    Source

    new_with_clamp

    fn new_with_clamp(alpha: f64, hue: f64, saturation: f64, value: f64, clamp_values: bool) -> Self
    

    Initializes a new instance of the HsvColor struct.

    This constructor exists only for internal use where performance is critical. Whether or not the channel values are in the correct range must be known: when clamp_values is false the components are stored as given.

    Source

    from_color

    fn from_color(color: Color) -> Self
    

    Initializes a new instance of the HsvColor struct from an RGB color.

    Source

    equals

    fn equals(self: &Self, other: HsvColor) -> bool
    

    Source

    to_rgb

    fn to_rgb(self: &Self) -> Color
    

    Returns the RGB color model equivalent of this HSV color.

    Source

    to_hsl

    fn to_hsl(self: &Self) -> HslColor
    

    Returns the HSL color model equivalent of this HSV color.

    Source

    to_string_format

    fn to_string_format(self: &Self, format: Option<&str>, format_provider: Option<&CultureInfo>) -> Result<String, FormatError>
    

    Returns the string representation of the color using a format specifier.

    Supported format specifiers:

    • V / v: hsva(h, s%, v%, a) / hsv(h, s%, v%)
    • V% / v%: hsva(h%, s%, v%, a%) / hsv(h%, s%, v%)
    • X, x, H, R, r, R%, r%: converted to RGB and formatted as such
    • L, l, L%, l%: converted to HSL and formatted as such

    A null or empty format is the same as to_string(). Any other format is an error. format_provider is ignored: color formatting is culture-invariant.

    Source

    parse

    fn parse(s: &str) -> Result<HsvColor, FormatError>
    

    Parses an HSV color string (hsv(h, s, v) or hsva(h, s, v, a)).

    Source

    try_parse

    fn try_parse(s: &str) -> Option<HsvColor>
    

    Parses an HSV color string (hsv(h, s, v) or hsva(h, s, v, a)), returning None when it is not valid. Saturation, value and alpha may be given as fractions or percentages.

    Source

    from_ahsv

    fn from_ahsv(a: f64, h: f64, s: f64, v: f64) -> HsvColor
    

    Creates an HsvColor from alpha, hue, saturation and value (clamped).

    Source

    from_hsv

    fn from_hsv(h: f64, s: f64, v: f64) -> HsvColor
    

    Creates an opaque HsvColor from hue, saturation and value (clamped).

    Source

    hsv_to_rgb

    fn hsv_to_rgb(hue: f64, saturation: f64, value: f64, alpha: f64) -> Color
    

    Converts the given HSVA color component values to their RGB color equivalent.

    The hue is wrapped into [0, 360); the other components are clamped to 0..1.

    Source

    hsv_to_hsl

    fn hsv_to_hsl(hue: f64, saturation: f64, value: f64, alpha: f64) -> HslColor
    

    Converts the given HSVA color component values to their HSL color equivalent.

    Source

    Trait implementations

    • Send
    • Sync
    • Freeze
    • UnsafeUnpin
    • Unpin
    • UnwindSafe
    • RefUnwindSafe
    • PropertyValue
    • AnyValue
    • ClassDefaults
    • Borrow<T>
    • BorrowMut<T>
    • CloneToUninit
    • Into<U>
    • From<T>
    • TryInto<U>
    • TryFrom<U>
    • Any
    • ToOwned
    • ToString
    • ErasedDestructor
    • IntoEither
    • Clone
    • Copy
    • Debug
    • StructuralPartialEq
    • PartialEq
    • Default
    • From<HsvColor>
    • FromStr
    • Display
    • MarkupTyped
    • ValueTypeRegistration

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.