use crate::pdfium_types::FPDF_DWORD;
#[derive(Debug, Copy, Clone)]
pub struct PdfiumColor {
red: u8,
green: u8,
blue: u8,
alpha: u8,
}
impl PdfiumColor {
pub const WHITE: PdfiumColor = PdfiumColor::new(255, 255, 255, 255);
pub const BLACK: PdfiumColor = PdfiumColor::new(0, 0, 0, 255);
pub const RED: PdfiumColor = PdfiumColor::new(255, 0, 0, 255);
pub const GREEN: PdfiumColor = PdfiumColor::new(0, 128, 0, 255);
pub const BLUE: PdfiumColor = PdfiumColor::new(0, 0, 255, 255);
pub const YELLOW: PdfiumColor = PdfiumColor::new(255, 255, 0, 255);
pub const MAGENTA: PdfiumColor = PdfiumColor::new(255, 0, 255, 255);
pub const CYAN: PdfiumColor = PdfiumColor::new(0, 255, 255, 255);
pub const fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Self {
Self {
red,
green,
blue,
alpha,
}
}
}
impl From<&PdfiumColor> for FPDF_DWORD {
fn from(value: &PdfiumColor) -> Self {
let red = value.red as FPDF_DWORD;
let green = value.green as FPDF_DWORD;
let blue = value.blue as FPDF_DWORD;
let alpha = value.alpha as FPDF_DWORD;
(alpha << 24) | (red << 16) | (green << 8) | blue
}
}