Table of Contents

Class InkColor

Namespace
Egami.Colors
Assembly
Egami.dll

A colour given as inks: named colorants with tints, as PDF's Separation and DeviceN colours, plus the appearance other backends draw. An ink canvas paints each named ink's plate; an RGB canvas, SVG or a raster without the ink draws Appearance. Immutable.

public sealed class InkColor : IEquatable<InkColor>
Inheritance
InkColor
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

Remarks

A colour names its inks; under overprint only those plates are painted. Cmyk(float, float, float, float) names all four process inks, even at 0, and is marked IsCmyk, so overprint's NonZero mode can leave its zero components alone, as PDF's overprint mode 1 does for DeviceCMYK. A colour mixing the same inks by Mix(params ReadOnlySpan<InkTint>) is not marked: its zeros are painted.

Properties

Appearance

Gets how the colour looks where its inks cannot be printed: the inks' appearances, each scaled by its tint, printed over one another (see InkAppearance); null when no ink has one, so nothing shows there.

public InkAppearance? Appearance { get; }

Property Value

InkAppearance?

Inks

Gets the inks and their tints, in the order given.

public IReadOnlyList<InkTint> Inks { get; }

Property Value

IReadOnlyList<InkTint>

IsCmyk

Gets a value indicating whether this is a process CMYK colour made by Cmyk(float, float, float, float).

public bool IsCmyk { get; }

Property Value

bool

None

Gets paper: no ink at all. Drawn without overprint, it clears every plate; its appearance is white.

public static InkColor None { get; }

Property Value

InkColor

Methods

Cmyk(float, float, float, float)

Returns a process CMYK colour: the four process inks, each named even at 0.

public static InkColor Cmyk(float c, float m, float y, float k)

Parameters

c float

Cyan, 0 to 1.

m float

Magenta, 0 to 1.

y float

Yellow, 0 to 1.

k float

Black, 0 to 1.

Returns

InkColor

The colour.

Exceptions

ArgumentOutOfRangeException

A tint is outside 0 to 1.

Equals(InkColor?)

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

public bool Equals(InkColor? other)

Parameters

other InkColor

An object to compare with this object.

Returns

bool

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

Equals(object?)

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

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

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

IndexOf(string)

Returns the index in Inks of the ink named name (ordinal), or −1.

public int IndexOf(string name)

Parameters

name string

The ink's name.

Returns

int

The index, or −1.

Mix(params ReadOnlySpan<InkTint>)

Returns several inks at their tints, as PDF's DeviceN colour.

public static InkColor Mix(params ReadOnlySpan<InkTint> inks)

Parameters

inks ReadOnlySpan<InkTint>

The inks, each named once; at most MaxInks.

Returns

InkColor

The colour.

Exceptions

ArgumentException

An ink is named twice, or there are more than MaxInks.

ArgumentNullException

A colorant is null.

ArgumentOutOfRangeException

A tint is outside 0 to 1.

Spot(Colorant, float)

Returns one ink at a tint, as PDF's Separation colour.

public static InkColor Spot(Colorant colorant, float tint)

Parameters

colorant Colorant

The ink.

tint float

The tint, 0 to 1.

Returns

InkColor

The colour.

Exceptions

ArgumentNullException

colorant is null.

ArgumentOutOfRangeException

tint is outside 0 to 1.

Spot(string, float, InkAppearance?)

Returns a spot colour at a tint.

public static InkColor Spot(string name, float tint, InkAppearance? appearance)

Parameters

name string

The spot's name, such as PANTONE 186 C.

tint float

The tint, 0 to 1.

appearance InkAppearance?

How the spot looks at full tint, or null to draw nothing where it cannot be printed.

Returns

InkColor

The colour.

Exceptions

ArgumentException

name is not a valid spot name (see Spot(string, InkAppearance?)).

ArgumentOutOfRangeException

tint is outside 0 to 1.

TintOf(string)

Returns the tint of the ink named name, or null when the colour does not name it.

public float? TintOf(string name)

Parameters

name string

The ink's name.

Returns

float?

The tint, or null.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.