Expand description
Representation of the <color>
type.
Fields§
§red: u8
§green: u8
§blue: u8
Implementations§
Trait Implementations§
source§impl From<Color> for AttributeValue
impl From<Color> for AttributeValue
source§impl FromStr for Color
impl FromStr for Color
source§fn from_str(text: &str) -> Result<Color, Error>
fn from_str(text: &str) -> Result<Color, Error>
Parses Color
from StrSpan
.
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>
is followed by<icccolor>
. It’s not supported.
Notes
- Any non-
hexdigit
bytes will be treated as0
. - Allocates heap memory for case-insensitive named colors comparison.
source§impl WriteBuffer for Color
impl WriteBuffer for Color
source§fn write_buf_opt(&self, opt: &WriteOptions, buf: &mut Vec<u8, Global>)
fn write_buf_opt(&self, opt: &WriteOptions, buf: &mut Vec<u8, Global>)
Writes data to the
Vec<u8>
buffer using specified WriteOptions
.source§fn write_buf(&self, buf: &mut Vec<u8, Global>)
fn write_buf(&self, buf: &mut Vec<u8, Global>)
Writes data to the
Vec<u8>
buffer using default WriteOptions
.source§fn with_write_opt<'a>(&'a self, opt: &'a WriteOptions) -> DisplaySvg<'a, Self>where
Self: Sized,
fn with_write_opt<'a>(&'a self, opt: &'a WriteOptions) -> DisplaySvg<'a, Self>where
Self: Sized,
Returns an object that implements
fmt::Display
using provided write options.