pub struct PdfColor { /* private fields */ }
Expand description

A 32-bit RGB color value with an optional alpha channel.

A variety of non-transparent colors are available as const values on this struct.

Note that when used as a form field highlight color, a solid color with no opacity will overprint any user data in the field. Use the PdfColor::with_alpha() function to apply an alpha channel value to an existing PdfColor.

Implementations§

source§

impl PdfColor

source

pub const WHITE: PdfColor = _

source

pub const BLACK: PdfColor = _

source

pub const SOLID_WHITE: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::WHITE instead.
source

pub const SOLID_RED: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::RED instead.
source

pub const SOLID_GREEN: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::GREEN instead.
source

pub const SOLID_BLUE: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::BLUE instead.
source

pub const SOLID_MAGENTA: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::MAGENTA instead.
source

pub const SOLID_CYAN: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::CYAN instead.
source

pub const SOLID_YELLOW: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::YELLOW instead.
source

pub const SOLID_BLACK: PdfColor = _

👎Deprecated since 0.8.6: The SOLID_ prefix is superfluous. Use PdfColor::BLACK instead.
source

pub const GREY_90: PdfColor = _

source

pub const GREY_80: PdfColor = _

source

pub const GREY_70: PdfColor = _

source

pub const GREY_60: PdfColor = _

source

pub const GREY_50: PdfColor = _

source

pub const GREY_40: PdfColor = _

source

pub const GREY_30: PdfColor = _

source

pub const GREY_20: PdfColor = _

source

pub const GREY_10: PdfColor = _

source

pub const LIME: PdfColor = _

source

pub const BLUE: PdfColor = _

source

pub const YELLOW: PdfColor = _

source

pub const CYAN: PdfColor = _

source

pub const MAGENTA: PdfColor = _

source

pub const SILVER: PdfColor = _

source

pub const OLIVE: PdfColor = _

source

pub const PURPLE: PdfColor = _

source

pub const TEAL: PdfColor = _

source

pub const NAVY: PdfColor = _

source

pub const MAROON: PdfColor = _

source

pub const DARK_RED: PdfColor = _

source

pub const BROWN: PdfColor = _

source

pub const FIREBRICK: PdfColor = _

source

pub const CRIMSON: PdfColor = _

source

pub const RED: PdfColor = _

source

pub const TOMATO: PdfColor = _

source

pub const CORAL: PdfColor = _

source

pub const INDIAN_RED: PdfColor = _

source

pub const LIGHT_CORAL: PdfColor = _

source

pub const DARK_SALMON: PdfColor = _

source

pub const SALMON: PdfColor = _

source

pub const LIGHT_SALMON: PdfColor = _

source

pub const ORANGE_RED: PdfColor = _

source

pub const DARK_ORANGE: PdfColor = _

source

pub const ORANGE: PdfColor = _

source

pub const GOLD: PdfColor = _

source

pub const DARK_GOLDEN_ROD: PdfColor = _

source

pub const GOLDEN_ROD: PdfColor = _

source

pub const PALE_GOLDEN_ROD: PdfColor = _

source

pub const DARK_KHAKI: PdfColor = _

source

pub const KHAKI: PdfColor = _

source

pub const YELLOW_GREEN: PdfColor = _

source

pub const DARK_OLIVE_GREEN: PdfColor = _

source

pub const OLIVE_DRAB: PdfColor = _

source

pub const LAWN_GREEN: PdfColor = _

source

pub const CHARTREUSE: PdfColor = _

source

pub const GREEN_YELLOW: PdfColor = _

source

pub const DARK_GREEN: PdfColor = _

source

pub const GREEN: PdfColor = _

source

pub const FOREST_GREEN: PdfColor = _

source

pub const LIME_GREEN: PdfColor = _

source

pub const LIGHT_GREEN: PdfColor = _

source

pub const PALE_GREEN: PdfColor = _

source

pub const DARK_SEA_GREEN: PdfColor = _

source

pub const MEDIUM_SPRING_GREEN: PdfColor = _

source

pub const SPRING_GREEN: PdfColor = _

source

pub const SEA_GREEN: PdfColor = _

source

pub const MEDIUM_AQUA_MARINE: PdfColor = _

source

pub const MEDIUM_SEA_GREEN: PdfColor = _

source

pub const LIGHT_SEA_GREEN: PdfColor = _

source

pub const DARK_SLATE_GRAY: PdfColor = _

source

pub const DARK_CYAN: PdfColor = _

source

pub const AQUA: PdfColor = _

source

pub const LIGHT_CYAN: PdfColor = _

source

pub const DARK_TURQUOISE: PdfColor = _

source

pub const TURQUOISE: PdfColor = _

source

pub const MEDIUM_TURQUOISE: PdfColor = _

source

pub const PALE_TURQUOISE: PdfColor = _

source

pub const AQUA_MARINE: PdfColor = _

source

pub const POWDER_BLUE: PdfColor = _

source

pub const CADET_BLUE: PdfColor = _

source

pub const STEEL_BLUE: PdfColor = _

source

pub const CORNFLOWER_BLUE: PdfColor = _

source

pub const DEEP_SKY_BLUE: PdfColor = _

source

pub const DODGER_BLUE: PdfColor = _

source

pub const LIGHT_BLUE: PdfColor = _

source

pub const SKY_BLUE: PdfColor = _

source

pub const LIGHT_SKY_BLUE: PdfColor = _

source

pub const MIDNIGHT_BLUE: PdfColor = _

source

pub const DARK_BLUE: PdfColor = _

source

pub const MEDIUM_BLUE: PdfColor = _

source

pub const ROYAL_BLUE: PdfColor = _

source

pub const BLUE_VIOLET: PdfColor = _

source

pub const INDIGO: PdfColor = _

source

pub const DARK_SLATE_BLUE: PdfColor = _

source

pub const SLATE_BLUE: PdfColor = _

source

pub const MEDIUM_SLATE_BLUE: PdfColor = _

source

pub const MEDIUM_PURPLE: PdfColor = _

source

pub const DARK_MAGENTA: PdfColor = _

source

pub const DARK_VIOLET: PdfColor = _

source

pub const DARK_ORCHID: PdfColor = _

source

pub const MEDIUM_ORCHID: PdfColor = _

source

pub const THISTLE: PdfColor = _

source

pub const PLUM: PdfColor = _

source

pub const VIOLET: PdfColor = _

source

pub const ORCHID: PdfColor = _

source

pub const MEDIUM_VIOLET_RED: PdfColor = _

source

pub const PALE_VIOLET_RED: PdfColor = _

source

pub const DEEP_PINK: PdfColor = _

source

pub const HOT_PINK: PdfColor = _

source

pub const LIGHT_PINK: PdfColor = _

source

pub const PINK: PdfColor = _

source

pub const ANTIQUE_WHITE: PdfColor = _

source

pub const BEIGE: PdfColor = _

source

pub const BISQUE: PdfColor = _

source

pub const BLANCHED_ALMOND: PdfColor = _

source

pub const WHEAT: PdfColor = _

source

pub const CORN_SILK: PdfColor = _

source

pub const LEMON_CHIFFON: PdfColor = _

source

pub const LIGHT_GOLDEN_ROD_YELLOW: PdfColor = _

source

pub const LIGHT_YELLOW: PdfColor = _

source

pub const SADDLE_BROWN: PdfColor = _

source

pub const SIENNA: PdfColor = _

source

pub const CHOCOLATE: PdfColor = _

source

pub const PERU: PdfColor = _

source

pub const SANDY_BROWN: PdfColor = _

source

pub const BURLY_WOOD: PdfColor = _

source

pub const TAN: PdfColor = _

source

pub const ROSY_BROWN: PdfColor = _

source

pub const MOCCASIN: PdfColor = _

source

pub const NAVAJO_WHITE: PdfColor = _

source

pub const PEACH_PUFF: PdfColor = _

source

pub const MISTY_ROSE: PdfColor = _

source

pub const LAVENDER_BLUSH: PdfColor = _

source

pub const LINEN: PdfColor = _

source

pub const OLD_LACE: PdfColor = _

source

pub const PAPAYA_WHIP: PdfColor = _

source

pub const SEA_SHELL: PdfColor = _

source

pub const MINT_CREAM: PdfColor = _

source

pub const SLATE_GRAY: PdfColor = _

source

pub const LIGHT_SLATE_GRAY: PdfColor = _

source

pub const LIGHT_STEEL_BLUE: PdfColor = _

source

pub const LAVENDER: PdfColor = _

source

pub const FLORAL_WHITE: PdfColor = _

source

pub const ALICE_BLUE: PdfColor = _

source

pub const GHOST_WHITE: PdfColor = _

source

pub const HONEYDEW: PdfColor = _

source

pub const IVORY: PdfColor = _

source

pub const AZURE: PdfColor = _

source

pub const SNOW: PdfColor = _

source

pub const DIM_GREY: PdfColor = _

source

pub const GREY: PdfColor = _

source

pub const DARK_GREY: PdfColor = _

source

pub const LIGHT_GREY: PdfColor = _

source

pub const GAINSBORO: PdfColor = _

source

pub const WHITE_SMOKE: PdfColor = _

source

pub const fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Self

Constructs a new PdfColor object from the given arguments.

source

pub fn from_hex(hex: &str) -> Result<Self, PdfiumError>

Returns the result of importing the given hexadecimal color specification, as in HTML. For example, #800080 represents a shade of purple with 100% opacity, and #40800080 is the same shade of purple with 25% opacity. The leading hash symbol is required.

source

pub const fn mix(a: &PdfColor, b: &PdfColor) -> Self

Returns the result of averaging the RGB and alpha values of the two given PdfColor objects.

source

pub const fn mix_with(&self, other: &PdfColor) -> Self

Returns the result of averaging the RGB and alpha values of this PdfColor with the given PdfColor.

source

pub const fn with_alpha(&self, alpha: u8) -> Self

Constructs a new PdfColor by copying the red, green, and blue color components of this color and applying the given alpha value.

source

pub fn alpha(&self) -> u8

Returns the alpha (opacity) component of this color, with 0 = completely transparent and 255 = completely opaque (solid).

source

pub fn red(&self) -> u8

Returns the red component of this color.

source

pub fn green(&self) -> u8

Returns the green component of this color.

source

pub fn blue(&self) -> u8

Returns the blue component of this color.

source

pub fn to_hex(&self) -> String

Returns the hexadecimal representation of this color, as in HTML, without a leading hash symbol. Excludes the alpha channel value. For example, PdfColor::PURPLE.to_hex() will return “800080”.

source

pub fn to_hex_with_alpha(&self) -> String

Returns the hexadecimal representation of this color, as in HTML, without a leading hash symbol. Includes the alpha channel value. For example, PdfColor::PURPLE.to_hex_with_alpha() will return “FF800080”.

Trait Implementations§

source§

impl Clone for PdfColor

source§

fn clone(&self) -> PdfColor

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for PdfColor

source§

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

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

impl Copy for PdfColor

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.