Skip to content

PdfColor struct

View as Markdown

Namespace: PdfNetStack.Drawing
Assembly: PdfNetStack.dll
Package: PdfNetStack

A device color with an opacity. Components are 0 to 1. Opacity below 1 is written as a constant alpha graphics state.

public readonly struct PdfColor : IEquatable<PdfColor>

Implements

IEquatable<PdfColor>

Opacity, 0 transparent to 1 opaque.

public double Alpha { get; }

double

Opaque black.

public static PdfColor Black { get; }

PdfColor

The color model.

public PdfColorSpace Space { get; }

PdfColorSpace

Fully transparent.

public static PdfColor Transparent { get; }

PdfColor

Opaque white.

public static PdfColor White { get; }

PdfColor

Cmyk(double, double, double, double, double)

Section titled “ Cmyk(double, double, double, double, double)”

A CMYK color with components 0 to 1.

public static PdfColor Cmyk(double cyan, double magenta, double yellow, double black, double alpha = 1)

cyan double

magenta double

yellow double

black double

alpha double

PdfColor

The components in the order the color space defines: 1, 3 or 4 values.

public double[] Components()

double[]

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

public bool Equals(PdfColor other)

other PdfColor

An object to compare with this object.

bool

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

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

obj object?

The object to compare with the current instance.

bool

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

Parses #RGB, #RGBA, #RRGGBB or #RRGGBBAA, with or without the hash.

public static PdfColor FromHex(string hex)

hex string

PdfColor

FormatException

The text is not a hex color.

An RGB color with components 0 to 255, as in CSS and most image tools.

public static PdfColor FromRgb(byte red, byte green, byte blue, double alpha = 1)

red byte

green byte

blue byte

alpha double

PdfColor

Returns the hash code for this instance.

public override int GetHashCode()

int

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

A gray level, 0 black to 1 white.

public static PdfColor Gray(double level, double alpha = 1)

level double

alpha double

PdfColor

An RGB color with components 0 to 1.

public static PdfColor Rgb(double red, double green, double blue, double alpha = 1)

red double

green double

blue double

alpha double

PdfColor

The color converted to RGB (CMYK by the naive formula, without a color profile).

public PdfColor ToRgb()

PdfColor

Returns the fully qualified type name of this instance.

public override string ToString()

string

The fully qualified type name.

The same color with another opacity.

public PdfColor WithAlpha(double alpha)

alpha double

PdfColor

Equality.

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

left PdfColor

right PdfColor

bool

Inequality.

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

left PdfColor

right PdfColor

bool