pub struct HighlightColor {
pub r: u8,
pub g: u8,
pub b: u8,
}Expand description
A color representation suitable for PDF rendering using RGB values.
This struct wraps RGB color values (0-255 for each channel) commonly used in syntax highlighting to represent text colors in generated PDFs.
§Fields
r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)
§Examples
Create a color directly from RGB values:
use markdown2pdf::highlighting::HighlightColor;
let red = HighlightColor::from_rgb(255, 0, 0);
assert_eq!(red.r, 255);
assert_eq!(red.g, 0);
assert_eq!(red.b, 0);Convert from a syntect Color and retrieve as tuple:
use markdown2pdf::highlighting::HighlightColor;
let blue = HighlightColor::from_rgb(0, 100, 200);
let (r, g, b) = blue.as_rgb_u8();
assert_eq!((r, g, b), (0, 100, 200));Fields§
§r: u8§g: u8§b: u8Implementations§
Source§impl HighlightColor
impl HighlightColor
Sourcepub fn from_rgb(r: u8, g: u8, b: u8) -> Self
pub fn from_rgb(r: u8, g: u8, b: u8) -> Self
Creates a new color from RGB component values.
§Arguments
r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)
§Examples
use markdown2pdf::highlighting::HighlightColor;
let color = HighlightColor::from_rgb(128, 64, 200);
assert_eq!(color.r, 128);
assert_eq!(color.g, 64);
assert_eq!(color.b, 200);Sourcepub fn from_syntect_color(color: Color) -> Self
pub fn from_syntect_color(color: Color) -> Self
Converts a syntect Color to a HighlightColor.
This method extracts the RGB components from a syntect Color struct, which is used internally by the syntect syntax highlighting library.
§Arguments
color- A syntect Color object with RGB components
§Examples
use markdown2pdf::highlighting::HighlightColor;
use syntect::highlighting::Color;
let syntect_color = Color {
r: 200,
g: 100,
b: 50,
a: 255,
};
let highlight_color = HighlightColor::from_syntect_color(syntect_color);
assert_eq!(highlight_color.r, 200);
assert_eq!(highlight_color.g, 100);
assert_eq!(highlight_color.b, 50);Sourcepub fn as_rgb_u8(&self) -> (u8, u8, u8)
pub fn as_rgb_u8(&self) -> (u8, u8, u8)
Converts the color to a tuple of RGB values.
§Returns
A tuple (r, g, b) containing the red, green, and blue components.
§Examples
use markdown2pdf::highlighting::HighlightColor;
let color = HighlightColor::from_rgb(100, 150, 200);
let (r, g, b) = color.as_rgb_u8();
assert_eq!(r, 100);
assert_eq!(g, 150);
assert_eq!(b, 200);Trait Implementations§
Source§impl Clone for HighlightColor
impl Clone for HighlightColor
Source§fn clone(&self) -> HighlightColor
fn clone(&self) -> HighlightColor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HighlightColor
impl Debug for HighlightColor
Source§impl PartialEq for HighlightColor
impl PartialEq for HighlightColor
impl Copy for HighlightColor
impl Eq for HighlightColor
impl StructuralPartialEq for HighlightColor
Auto Trait Implementations§
impl Freeze for HighlightColor
impl RefUnwindSafe for HighlightColor
impl Send for HighlightColor
impl Sync for HighlightColor
impl Unpin for HighlightColor
impl UnwindSafe for HighlightColor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.