Struct lyon_svg::parser::RgbColor
[−]
[src]
pub struct RgbColor {
pub red: u8,
pub green: u8,
pub blue: u8,
}Representation of the <color> type.
Fields
red: u8
green: u8
blue: u8
Methods
impl RgbColor
fn new(red: u8, green: u8, blue: u8) -> RgbColor
Constructs a new RgbColor from red, green and blue values.
fn from_stream(s: &mut Stream) -> Result<RgbColor, Error>
Parses RgbColor from the Stream.
Parsing is done according to spec:
color ::= "#" hexdigit hexdigit hexdigit (hexdigit hexdigit hexdigit)?
| "rgb(" wsp* integer comma integer comma integer wsp* ")"
| "rgb(" wsp* integer "%" comma integer "%" comma integer "%" wsp* ")"
| color-keyword
hexdigit ::= [0-9A-Fa-f]
comma ::= wsp* "," wsp*
* The SVG spec has an error. There should be number,
not an integer for percent values (details).
Errors
Returns error if a color has an invalid format.
Returns error if
color-keywordorrgbprefix are in in the lowercase. It's not supported.Returns error if
<color>is followed by<icccolor>. It's not supported.
Notes
- Any non-
hexdigitbytes will be treated as0.
Trait Implementations
impl Copy for RgbColor
impl PartialEq<RgbColor> for RgbColor
fn eq(&self, __arg_0: &RgbColor) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &RgbColor) -> bool
This method tests for !=.
impl Debug for RgbColor
fn fmt(&self, __arg_0: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter.
impl Clone for RgbColor
fn clone(&self) -> RgbColor
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more