Struct usvg::tree::Color
[−]
[src]
pub struct Color { pub red: u8, pub green: u8, pub blue: u8, }
Representation of the <color>
type.
Fields
red: u8
green: u8
blue: u8
Methods
impl Color
[src]
pub fn new(red: u8, green: u8, blue: u8) -> Color
[src]
Constructs a new Color
from red
, green
and blue
values.
Trait Implementations
impl From<Color> for AttributeValue
[src]
fn from(value: Color) -> AttributeValue
[src]
Performs the conversion.
impl Display for Color
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter. Read more
impl WriteBuffer for Color
[src]
fn write_buf_opt(&self, opt: &WriteOptions, buf: &mut Vec<u8>)
[src]
Writes data to the Vec<u8>
buffer using specified WriteOptions
.
fn write_buf(&self, buf: &mut Vec<u8>)
[src]
Writes data to the Vec<u8>
buffer using default WriteOptions
.
fn with_write_opt(&'a self, opt: &'a WriteOptions) -> DisplaySvg<'a, Self>
[src]
Returns an object that implements fmt::Display
using provided write options.
impl FromSpan for Color
[src]
fn from_span(span: StrSpan) -> Result<Color, Error>
[src]
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.
impl Copy for Color
[src]
impl FromStr for Color
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Color, <Color as FromStr>::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl PartialEq<Color> for Color
[src]
fn eq(&self, __arg_0: &Color) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Color) -> bool
[src]
This method tests for !=
.
impl Clone for Color
[src]
fn clone(&self) -> Color
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more