I try to draw an image and after the first drawing i want invert the color of the drawing.
If the background of my new square is black i need white and if it white i need black.
In my example i draw 3 squares and make a offset of 10 pixel in the x.
Unfortunately, it does not produce the wanted result.
using var skBitmap = new SKBitmap(100, 40);
using var skCanvas = new SKCanvas(skBitmap);
skCanvas.Clear(SKColors.White);
var color = SKColors.Black;
float[] invertMatrix = {
-1.0f, 0.0f, 0.0f, 0.0f, 255.0f,
0.0f, -1.0f, 0.0f, 0.0f, 255.0f,
0.0f, 0.0f, -1.0f, 0.0f, 255.0f,
0.0f, 0.0f, 0.0f, 1.0f, 0.0f
};
using var skPaint = new SKPaint();
skPaint.Color = color;
skPaint.Style = SKPaintStyle.Fill;
skCanvas.DrawRect(10, 10, 20, 20, skPaint);
skPaint.ColorFilter = SKColorFilter.CreateColorMatrix(invertMatrix);
//move +10 in x
skCanvas.DrawRect(20, 10, 20, 20, skPaint);
//move +10 in x
skCanvas.DrawRect(30, 10, 20, 20, skPaint);

I have found a solution for my problem unfortunately without a matrix.