Skip to main content

Color

Enum Color 

Source
pub enum Color {
    Rgb(String),
    RgbPercent {
        red: i64,
        green: i64,
        blue: i64,
    },
    Hsl {
        hue_60000ths: i32,
        saturation_1000ths_percent: i64,
        luminance_1000ths_percent: i64,
    },
    System {
        value: String,
        last_color: Option<String>,
    },
    Preset(String),
}
Expand description

A color (EG_ColorChoice): the choice DrawingML offers wherever a color is needed (fills, lines, gradient stops..).

Not modeled: scheme-relative colors (<a:schemeClr>, ST_SchemeColorVal — a reference into a theme’s 12-color palette) — deferred until a host crate can resolve a theme (see the project notes plan,: excel-ooxml has no configurable Theme model at all yet, and word-ooxml’s own Theme/Style/Run never reference a theme slot either — drawing has nothing to resolve against today). Color transforms (EG_ColorTransformalpha/lumMod/lumOff/shade/ tint/., applicable to every variant below) are not modeled either — each variant here is always a literal, unmodified color.

Variants§

§

Rgb(String)

<a:srgbClr val="RRGGBB"> — a literal RGB color, hex-encoded with no leading #. The overwhelmingly common case, same representation excel-ooxml/word-ooxml already use for their own literal colors.

§

RgbPercent

<a:scrgbClr r=".." g=".." b=".."> — a literal RGB color given as percentages, each in thousandths of a percent (ST_Percentage; 100000 = 100%).

Fields

§red: i64
§green: i64
§blue: i64
§

Hsl

<a:hslClr hue=".." sat=".." lum="..">. hue is ST_PositiveFixedAngle (60,000ths of a degree, 0.=21_600_000); saturation/luminance are ST_Percentage (thousandths of a percent).

Fields

§hue_60000ths: i32
§saturation_1000ths_percent: i64
§luminance_1000ths_percent: i64
§

System

<a:sysClr val=".." lastClr=".."> — one of the ~30 legacy Windows UI colors (ST_SystemColorVal, e.g. "windowText", "btnFace"). value is kept as the raw token rather than a closed enum (rarely used in real documents, same “not enumerated” posture as Preset below); last_color is the RGB fallback Office itself resolved it to at authoring time.

Fields

§value: String
§last_color: Option<String>
§

Preset(String)

<a:prstClr val=".."> — one of ST_PresetColorVal’s ~140 CSS-like named colors (e.g. "aliceBlue", "tomato"). Kept as the raw token rather than a closed enum, for the same reason as Color::System — see Color::Rgb for the common, literal-hex case.

Trait Implementations§

Source§

impl Clone for Color

Source§

fn clone(&self) -> Color

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Color

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Color

Source§

fn eq(&self, other: &Color) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Color

Auto Trait Implementations§

§

impl Freeze for Color

§

impl RefUnwindSafe for Color

§

impl Send for Color

§

impl Sync for Color

§

impl Unpin for Color

§

impl UnsafeUnpin for Color

§

impl UnwindSafe for Color

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.