Table of Contents

Struct GlyphColor

Namespace
Egami.Fonts
Assembly
Egami.Fonts.dll

A color in a color glyph: a resolved palette color, or the foreground (palette entry 0xFFFF), which takes the paint's color and keeps only this color's alpha as a factor.

public readonly record struct GlyphColor : IEquatable<GlyphColor>
Implements
Inherited Members

Examples

// Color glyphs draw in color by themselves: COLR (layers and gradients), sbix and CBDT (images), per glyph.
using (RasterCanvas<Rgba8> canvas = image.CreateCanvas())
{
    canvas.DrawText("Ship it", new Vector2(8, 40), new Font(text, 24), Rgba8.Black);
    canvas.DrawText("\U0001F680\U0001F389", new Vector2(100, 42), new Font(emoji, 32), Rgba8.Black);
}

// The palette is a font setting; the paint's color fills a glyph's foreground parts and its alpha the whole glyph.
var darkMode = new Font(emoji, 32) { Palette = FontPalette.Dark };
ColorGlyphFormats formats = emoji.ColorFormats;

// The paint graph is there to walk, for writers that draw color glyphs their own way.
emoji.TryGetColorGlyph(emoji.GetGlyph(0x1F680), darkMode.Palette, out ColorGlyph? rocket);

Constructors

GlyphColor(RgbaF32, bool)

A color in a color glyph: a resolved palette color, or the foreground (palette entry 0xFFFF), which takes the paint's color and keeps only this color's alpha as a factor.

public GlyphColor(RgbaF32 Color, bool IsForeground)

Parameters

Color RgbaF32

The color with straight alpha; for the foreground, the alpha to multiply the paint's by.

IsForeground bool

Whether this is the foreground color.

Examples

// Color glyphs draw in color by themselves: COLR (layers and gradients), sbix and CBDT (images), per glyph.
using (RasterCanvas<Rgba8> canvas = image.CreateCanvas())
{
    canvas.DrawText("Ship it", new Vector2(8, 40), new Font(text, 24), Rgba8.Black);
    canvas.DrawText("\U0001F680\U0001F389", new Vector2(100, 42), new Font(emoji, 32), Rgba8.Black);
}

// The palette is a font setting; the paint's color fills a glyph's foreground parts and its alpha the whole glyph.
var darkMode = new Font(emoji, 32) { Palette = FontPalette.Dark };
ColorGlyphFormats formats = emoji.ColorFormats;

// The paint graph is there to walk, for writers that draw color glyphs their own way.
emoji.TryGetColorGlyph(emoji.GetGlyph(0x1F680), darkMode.Palette, out ColorGlyph? rocket);

Properties

Color

The color with straight alpha; for the foreground, the alpha to multiply the paint's by.

public RgbaF32 Color { get; init; }

Property Value

RgbaF32

IsForeground

Whether this is the foreground color.

public bool IsForeground { get; init; }

Property Value

bool

Methods

Resolve(RgbaF32)

Returns the color to draw with a foreground color.

public RgbaF32 Resolve(RgbaF32 foreground)

Parameters

foreground RgbaF32

The paint's color.

Returns

RgbaF32

This color, or the foreground with this color's alpha multiplied in.