Table of Contents

Struct PdfColor

Namespace
MiPdf.Graphics
Assembly
MiPdf.dll

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

PdfColor

Blue

Blue (RGB 0, 0, 1).

public static readonly PdfColor Blue

Field Value

PdfColor

DarkGray

Dark gray (gray 0.4).

public static readonly PdfColor DarkGray

Field Value

PdfColor

Green

Green as in CSS (RGB 0, 0.5, 0); for full green use Lime.

public static readonly PdfColor Green

Field Value

PdfColor

LightGray

Light gray (gray 0.83).

public static readonly PdfColor LightGray

Field Value

PdfColor

Lime

Full green (RGB 0, 1, 0), named lime as in CSS.

public static readonly PdfColor Lime

Field Value

PdfColor

Orange

Orange (RGB 1, 0.65, 0).

public static readonly PdfColor Orange

Field Value

PdfColor

Red

Red (RGB 1, 0, 0).

public static readonly PdfColor Red

Field Value

PdfColor

White

White (gray 1).

public static readonly PdfColor White

Field Value

PdfColor

Yellow

Yellow (RGB 1, 1, 0).

public static readonly PdfColor Yellow

Field Value

PdfColor

Properties

C1

First component: gray level, red or cyan, depending on ColorSpace.

public double C1 { get; }

Property Value

double

C2

Second component: green or magenta (0 for gray).

public double C2 { get; }

Property Value

double

C3

Third component: blue or yellow (0 for gray).

public double C3 { get; }

Property Value

double

C4

Fourth component: black for CMYK (0 otherwise).

public double C4 { get; }

Property Value

double

ColorSpace

The device color space the components refer to.

public PdfColorSpace ColorSpace { get; }

Property Value

PdfColorSpace

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

c double
m double
y double
k double

Returns

PdfColor

FromHex(string)

Parses "#RGB", "#RRGGBB" (the '#' is optional).

public static PdfColor FromHex(string hex)

Parameters

hex string

Returns

PdfColor

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

r byte
g byte
b byte

Returns

PdfColor

Gray(double)

Creates a gray color (0 = black, 1 = white); the value is clamped to 0..1.

public static PdfColor Gray(double gray)

Parameters

gray double

Returns

PdfColor

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)

Parameters

r double
g double
b double

Returns

PdfColor