pub struct Color { /* private fields */ }Expand description
A <w:color> color property.
val is an RRGGBB hex string (or auto). The optional theme fields let
the color reference a document-theme color instead of being locked to the
hex value: when present they emit w:themeColor / w:themeShade /
w:themeTint, and Word resolves the color from the active theme while
val stays as a fallback for renderers that ignore themes.
use docx_rs::{Color, ThemeColor};
// Plain hex color (unchanged behavior).
let c = Color::new("2E74B5");
// Theme-aware color: "use accent1, shaded to BF", with 2E74B5 as fallback.
let c = Color::new("2E74B5")
.theme_color(ThemeColor::Accent1)
.theme_shade("BF");Implementations§
Source§impl Color
impl Color
Sourcepub fn new(val: impl Into<String>) -> Color
pub fn new(val: impl Into<String>) -> Color
Creates a color from an RRGGBB hex string (or auto).
Sourcepub fn theme_color(self, theme_color: ThemeColor) -> Color
pub fn theme_color(self, theme_color: ThemeColor) -> Color
Sets the theme color reference (w:themeColor).
Sourcepub fn theme_shade(self, theme_shade: impl Into<String>) -> Color
pub fn theme_shade(self, theme_shade: impl Into<String>) -> Color
Sets the theme shade modifier (w:themeShade), a hex byte such as "BF".
Sourcepub fn theme_tint(self, theme_tint: impl Into<String>) -> Color
pub fn theme_tint(self, theme_tint: impl Into<String>) -> Color
Sets the theme tint modifier (w:themeTint), a hex byte such as "99".
Trait Implementations§
impl BuildXML for Color
Source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more