pivot_pdf/graphics.rs
1/// RGB color for PDF graphics operations.
2///
3/// Each component is in the range 0.0 (none) to 1.0 (full intensity).
4#[derive(Debug, Clone, Copy, PartialEq)]
5pub struct Color {
6 /// Red component (0.0–1.0).
7 pub r: f64,
8 /// Green component (0.0–1.0).
9 pub g: f64,
10 /// Blue component (0.0–1.0).
11 pub b: f64,
12}
13
14impl Color {
15 /// Create a color from RGB components (each 0.0–1.0).
16 pub fn rgb(r: f64, g: f64, b: f64) -> Self {
17 Color { r, g, b }
18 }
19
20 /// Create a grayscale color (r = g = b = level).
21 pub fn gray(level: f64) -> Self {
22 Color {
23 r: level,
24 g: level,
25 b: level,
26 }
27 }
28}