PdfColor Struct

A color in a device color space (ISO 32000-2, 8.6.4): gray, RGB or CMYK, with components from 0 to 1.

public readonly struct PdfColor : IEquatable<PdfColor>
Implements

Properties

NameDescription
BlackGets black, in the gray color space.
ColorSpaceGets the color space.
WhiteGets white, in the gray color space.

Gets black, in the gray color space.

public static PdfColor Black { get; }

Property value

PdfColor

ColorSpace

PdfColor.cs

Gets the color space.

public PdfDeviceColorSpace ColorSpace { get; }

Property value

PdfDeviceColorSpace

Gets white, in the gray color space.

public static PdfColor White { get; }

Property value

PdfColor

Methods

NameDescription
Equals(PdfColor)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Indicates whether this instance and a specified object are equal.
FromCmyk(double, double, double, double)Creates a CMYK color.
FromGray(double)Creates a gray color.
FromRgb(double, double, double)Creates an RGB color.
FromRgb24(byte, byte, byte)Creates an RGB color from components from 0 to 255.
GetComponents()Gets the components of the color: one for gray, three for RGB, four for CMYK.
GetHashCode()Returns the hash code for this instance.
ToString()Returns the fully qualified type name of this instance.

Equals overloads

Equals(PdfColor)

PdfColor.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(PdfColor other)
Parameters
other PdfColor
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

PdfColor.cs

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current instance.
Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.

FromCmyk(double, double, double, double)

PdfColor.cs

Creates a CMYK color.

public static PdfColor FromCmyk(double cyan, double magenta, double yellow, double black)

Parameters

cyan double
The cyan component, from 0 to 1.
magenta double
The magenta component, from 0 to 1.
yellow double
The yellow component, from 0 to 1.
black double
The black component, from 0 to 1.

Returns

PdfColor The color.

FromGray(double)

PdfColor.cs

Creates a gray color.

public static PdfColor FromGray(double gray)

Parameters

gray double
The gray level, from 0 (black) to 1 (white).

Returns

PdfColor The color.

FromRgb(double, double, double)

PdfColor.cs

Creates an RGB color.

public static PdfColor FromRgb(double red, double green, double blue)

Parameters

red double
The red component, from 0 to 1.
green double
The green component, from 0 to 1.
blue double
The blue component, from 0 to 1.

Returns

PdfColor The color.

FromRgb24(byte, byte, byte)

PdfColor.cs

Creates an RGB color from components from 0 to 255.

public static PdfColor FromRgb24(byte red, byte green, byte blue)

Parameters

red byte
The red component.
green byte
The green component.
blue byte
The blue component.

Returns

PdfColor The color.

GetComponents()

PdfColor.cs

Gets the components of the color: one for gray, three for RGB, four for CMYK.

public double[] GetComponents()

Returns

double[] The components.

GetHashCode()

PdfColor.cs

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int A 32-bit signed integer that is the hash code for this instance.

ToString()

PdfColor.cs

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string The fully qualified type name.

Operators

NameDescription
operator ==(PdfColor, PdfColor)Indicates whether two colors are equal.
operator !=(PdfColor, PdfColor)Indicates whether two colors are different.

operator ==(PdfColor, PdfColor)

PdfColor.cs

Indicates whether two colors are equal.

public static bool operator ==(PdfColor left, PdfColor right)

Parameters

left PdfColor
The first color.
right PdfColor
The second color.

Returns

bool true when the colors are equal.

operator !=(PdfColor, PdfColor)

PdfColor.cs

Indicates whether two colors are different.

public static bool operator !=(PdfColor left, PdfColor right)

Parameters

left PdfColor
The first color.
right PdfColor
The second color.

Returns

bool true when the colors are different.