Table of Contents

Class LayerOptions

Namespace
Egami.Drawing
Assembly
Egami.Drawing.dll

How a layer started by SaveLayer(LayerOptions?) is merged at the matching Restore(): filtered, masked, faded by Opacity and blended into what lies below with BlendMode, through the clip. A layer is what PDF calls a transparency group.

public sealed record LayerOptions : IEquatable<LayerOptions>
Inheritance
LayerOptions
Implements
Inherited Members

Examples

using (RasterCanvas<Rgba8> canvas = raster.CreateCanvas())
{
    // Group opacity: the overlapping circles fade as one shape, with no darker overlap.
    canvas.SaveLayer(0.5f);
    canvas.FillCircle(new Vector2(80, 100), 60, new Rgba8(200, 30, 30, 255));
    canvas.FillCircle(new Vector2(140, 100), 60, new Rgba8(200, 30, 30, 255));
    canvas.Restore();

    // A group blended with Multiply and blurred as a whole; the layer grows by the blur's reach, so nothing is cut.
    canvas.SaveLayer(new LayerOptions { BlendMode = BlendMode.Multiply, Filter = ops => ops.Blur(4) });
    canvas.FillRect(new RectF(180, 40, 90, 120), new Rgba8(40, 120, 220, 255));
    canvas.FillCircle(new Vector2(225, 100), 30, Rgba8.White);
    canvas.Restore();
}

Properties

Backdrop

Gets a chain of Egami operations run on what lies behind the layer when it starts; the result is the layer's first content, so a blur here frosts the glass a translucent panel is drawn on, as Skia's backdrop filter does. Only the part inside the clip is used. null (the default) starts the layer as Isolated says.

public Action<RasterOps>? Backdrop { get; init; }

Property Value

Action<RasterOps>

BlendMode

Gets how the layer combines with what lies below it. Defaults to SourceOver.

public BlendMode BlendMode { get; init; }

Property Value

BlendMode

Exceptions

ArgumentOutOfRangeException

The value is not defined.

Bounds

Gets a rectangle, in local coordinates at the time of the call, that limits the layer: nothing drawn outside it shows, and only its part inside the clip is allocated. null (the default) uses the clip alone.

public RectF? Bounds { get; init; }

Property Value

RectF?

Exceptions

ArgumentException

The rectangle is not finite.

ColorSpace

Gets the colour space the layer blends in on an InkCanvas, as a PDF transparency group's colour space: an RGB or gray encoding keeps the layer's process part in that space, converted into the canvas's process inks when the layer merges, while spots stay plates. null (the default) blends in the canvas's own inks. Other canvases ignore it.

public ColorProfile? ColorSpace { get; init; }

Property Value

ColorProfile

Exceptions

ArgumentException

The encoding is neither RGB nor gray.

Filter

Gets a chain of Egami operations run on the layer's pixels before it is merged: a blur, a drop shadow, a color matrix, any step that keeps the size. The layer is first grown by how far the chain reads past each pixel (Reach(Action<RasterOps>)), so a blur near the clip's edge still sees what was drawn just outside it. For a drop shadow, pass Expand = false. A vector backend draws a filtered layer through its raster fallback. null (the default) runs nothing.

public Action<RasterOps>? Filter { get; init; }

Property Value

Action<RasterOps>

Isolated

Gets a value indicating whether the layer starts transparent (true, the default) or as a copy of what lies below it, as a PDF non-isolated group, so blend modes inside it reach the backdrop. A non-isolated layer starts from the backdrop as Skia's InitWithPrevious does.

public bool Isolated { get; init; }

Property Value

bool

Knockout

Gets a value indicating whether the layer is a knockout group, as PDF's: each call drawn inside it composites with what the layer started as, not with the calls before it, and replaces them where it covers, by its coverage. Overlapping translucent shapes in a knockout group do not darken each other. Layers nested inside it merge as ordinary calls. Defaults to false.

public bool Knockout { get; init; }

Property Value

bool

Mask

Gets a soft mask the layer is multiplied by before it is merged, as a PDF soft mask. null (the default) for none.

public SoftMask? Mask { get; init; }

Property Value

SoftMask

Opacity

Gets the opacity the whole layer is merged with, 0 to 1: overlapping shapes inside fade as one. Defaults to 1.

public float Opacity { get; init; }

Property Value

float

Exceptions

ArgumentOutOfRangeException

The value is outside 0 to 1.