Struct PdfColor
A device color (gray, RGB or CMYK). Components are stored in the range 0..1. Gray(double), Rgb(double, double, double)
and Cmyk(double, double, double, double) take components in that range; the From... methods convert other notations:
FromRgb(byte, byte, byte) 8-bit values (0..255) and FromHex(string) hex strings such as "#1F4E79".
The named colors follow the CSS color names.
public readonly record struct PdfColor : IEquatable<PdfColor>
- Implements
- Inherited Members
Fields
Black
Black (gray 0).
public static readonly PdfColor Black
Field Value
Blue
Blue (RGB 0, 0, 1).
public static readonly PdfColor Blue
Field Value
DarkGray
Dark gray (gray 0.4).
public static readonly PdfColor DarkGray
Field Value
Green
Green as in CSS (RGB 0, 0.5, 0); for full green use Lime.
public static readonly PdfColor Green
Field Value
LightGray
Light gray (gray 0.83).
public static readonly PdfColor LightGray
Field Value
Lime
Full green (RGB 0, 1, 0), named lime as in CSS.
public static readonly PdfColor Lime
Field Value
Orange
Orange (RGB 1, 0.65, 0).
public static readonly PdfColor Orange
Field Value
Red
Red (RGB 1, 0, 0).
public static readonly PdfColor Red
Field Value
White
White (gray 1).
public static readonly PdfColor White
Field Value
Yellow
Yellow (RGB 1, 1, 0).
public static readonly PdfColor Yellow
Field Value
Properties
C1
First component: gray level, red or cyan, depending on ColorSpace.
public double C1 { get; }
Property Value
C2
Second component: green or magenta (0 for gray).
public double C2 { get; }
Property Value
C3
Third component: blue or yellow (0 for gray).
public double C3 { get; }
Property Value
C4
Fourth component: black for CMYK (0 otherwise).
public double C4 { get; }
Property Value
ColorSpace
The device color space the components refer to.
public PdfColorSpace ColorSpace { get; }
Property Value
Methods
Cmyk(double, double, double, double)
Creates a CMYK color from components in the range 0..1 (clamped).
public static PdfColor Cmyk(double c, double m, double y, double k)
Parameters
Returns
FromHex(string)
Parses "#RGB", "#RRGGBB" (the '#' is optional).
public static PdfColor FromHex(string hex)
Parameters
hexstring
Returns
FromRgb(byte, byte, byte)
Creates an RGB color from 8-bit components (0..255).
public static PdfColor FromRgb(byte r, byte g, byte b)
Parameters
Returns
Gray(double)
Creates a gray color (0 = black, 1 = white); the value is clamped to 0..1.
public static PdfColor Gray(double gray)
Parameters
graydouble
Returns
Rgb(double, double, double)
Creates an RGB color from components in the range 0..1 (clamped).
public static PdfColor Rgb(double r, double g, double b)