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.