Skip to content

Skia Extensions

Although SkiaSharp a very powerful rendering environment, sometimes there are still some comfort features missing when creating effects within it. This extension class will be continually updated to make it easier to use in effect extensions.

Currently, the following extensions are defined.

public static class SkiaExtensions
{
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static SKColor WithScale(this SKColor color, float scale)
    {
        if (scale > 1)
            scale = 1;
        else if (scale < 0)
            scale = 0;

        return new SKColor(
            (byte) Math.Round(color.Red * scale),
            (byte) Math.Round(color.Green * scale),
            (byte) Math.Round(color.Blue * scale));
    }
}