Skip to content
On this page

Construct from named color

You can use the from_name method to construct a color from a name.

Currently supported color names are:

Function signature

rust
impl Color {
  pub fn from_name(name: &str) -> Result<Self>
}

Parameters

  • name: The name of color.

Return value

  • Result<Self> - A Result containing the parsed color if successful, or an error if not.

Examples

rust
use color_art::Color;

let color = Color::from_name("yellow").unwrap();
let color = Color::from_name("水绿").unwrap();

Released under the MIT License.