편집

다음을 통해 공유


SKShader.CreateCompose Method

Definition

Overloads

CreateCompose(SKShader, SKShader)

Create a new compose shader, which combines two shaders by the SrcOver blend mode.

CreateCompose(SKShader, SKShader, SKBlendMode)

Create a new compose shader, which combines two shaders by a blend mode.

Examples

var info = new SKImageInfo(256, 256);
using (var surface = SKSurface.Create(info)) {
    SKCanvas canvas = surface.Canvas;

    canvas.Clear(SKColors.White);

    // create the first shader
    var colors = new SKColor[] {
        new SKColor(0, 255, 255),
        new SKColor(255, 0, 255),
        new SKColor(255, 255, 0),
        new SKColor(0, 255, 255)
    };
    var sweep = SKShader.CreateSweepGradient(new SKPoint(128, 128), colors, null);

    // create the second shader
    var turbulence = SKShader.CreatePerlinNoiseTurbulence(0.05f, 0.05f, 4, 0);

    // create the compose shader
    var shader = SKShader.CreateCompose(sweep, turbulence, SKBlendMode.SrcOver);

    // use the compose shader
    var paint = new SKPaint {
        Shader = shader
    };
    canvas.DrawPaint(paint);
}

The example above produces the following:

Compose Shader

Remarks

Create a new compose shader, which combines two shaders by a blend mode.

CreateCompose(SKShader, SKShader)

Create a new compose shader, which combines two shaders by the SrcOver blend mode.

public static SkiaSharp.SKShader CreateCompose (SkiaSharp.SKShader shaderA, SkiaSharp.SKShader shaderB);

Parameters

shaderA
SKShader

The colors from this shader are seen as the destination by the blend mode.

shaderB
SKShader

The colors from this shader are seen as the source by the blend mode.

Returns

Returns a new SKShader, or an empty shader on error. This function never returns null.

Applies to

CreateCompose(SKShader, SKShader, SKBlendMode)

Create a new compose shader, which combines two shaders by a blend mode.

public static SkiaSharp.SKShader CreateCompose (SkiaSharp.SKShader shaderA, SkiaSharp.SKShader shaderB, SkiaSharp.SKBlendMode mode);

Parameters

shaderA
SKShader

The colors from this shader are seen as the destination by the blend mode.

shaderB
SKShader

The colors from this shader are seen as the source by the blend mode.

mode
SKBlendMode

The blend mode that combines the two shaders.

Returns

Returns a new SKShader, or an empty shader on error. This function never returns null.

Applies to