Class Colorant
A named ink: a process ink, a spot colour or a technical ink, with how it looks for backends that cannot print it. Names are
matched exactly (ordinal, case-sensitive), as PDF matches them; the names Cyan, Magenta, Yellow and
Black always mean the process inks, as in PDF's DeviceN. Two colorants are equal when their names are.
public sealed class Colorant : IEquatable<Colorant>
- Inheritance
-
Colorant
- Implements
- Inherited Members
Examples
// The inks of a page: FOGRA39's process inks, a spot colour with how it looks, and a varnish that never shows.
InkSet inks = InkSet.FromProfile(ColorProfile.Fogra39)
.WithSpot("PANTONE 186 C", InkAppearance.Cmyk(0, 1, 0.81f, 0.04f))
.WithSpot("Varnish", null, ColorantKind.Technical);
// Colours as inks: process CMYK, the spot at 60%, and the spot over 30% black (a DeviceN colour).
InkColor text = InkColor.Cmyk(0, 0, 0, 1);
InkColor logo = InkColor.Spot(inks[4], 0.6f);
InkColor shadow = InkColor.Mix(new InkTint(Colorant.Black, 0.3f), new InkTint(inks[4], 1));
InkAppearance? onScreen = shadow.Appearance; // CMYK 0, 1, 0.81, 0.328: the spot's look printed over the black
Fields
MaxNameLength
The longest name accepted, in characters: PDF's limit on a name.
public const int MaxNameLength = 127
Field Value
Properties
Appearance
Gets how the ink looks at full tint on backends that cannot print it, or null when it should not show there (a technical ink always, other inks when no appearance was given).
public InkAppearance? Appearance { get; }
Property Value
Black
Gets the process black ink.
public static Colorant Black { get; }
Property Value
Cyan
Gets the process cyan ink.
public static Colorant Cyan { get; }
Property Value
IsCmyk
Gets a value indicating whether this is one of the four CMYK process inks.
public bool IsCmyk { get; }
Property Value
Kind
Gets what the ink is for.
public ColorantKind Kind { get; }
Property Value
Magenta
Gets the process magenta ink.
public static Colorant Magenta { get; }
Property Value
Name
Gets the ink's name.
public string Name { get; }
Property Value
Yellow
Gets the process yellow ink.
public static Colorant Yellow { get; }
Property Value
Methods
Equals(Colorant?)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Colorant? other)
Parameters
otherColorantAn object to compare with this object.
Returns
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
Process(string, InkAppearance?)
Returns a process ink of an n-colour profile, such as Orange; for Cyan, Magenta, Yellow and Black it returns the built-in inks.
public static Colorant Process(string name, InkAppearance? appearance)
Parameters
namestringThe ink's name.
appearanceInkAppearance?How the ink looks at full tint, or null for none.
Returns
- Colorant
The colorant.
Exceptions
- ArgumentException
nameis empty, longer than MaxNameLength, or All or None.
Spot(string, InkAppearance?)
Returns a spot colour.
public static Colorant Spot(string name, InkAppearance? appearance)
Parameters
namestringThe ink's name, such as
PANTONE 186 C.appearanceInkAppearance?How the ink looks at full tint, or null to leave it out where it cannot be printed.
Returns
- Colorant
The colorant.
Exceptions
- ArgumentException
nameis empty, longer than MaxNameLength, All or None, or names a process ink (Cyan, Magenta, Yellow, Black).
Technical(string)
Returns a technical ink, such as varnish: printed on its own plate, never shown in proofs or on other backends.
public static Colorant Technical(string name)
Parameters
namestringThe ink's name.
Returns
- Colorant
The colorant.
Exceptions
- ArgumentException
nameis empty, longer than MaxNameLength, All or None, or names a process ink.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.