有没有一种用SkiaSharp绘制可逆形状的方法?
对于可逆的,我指的是outColor = srcColor XOR dstColor,所以当你再次绘制相同的颜色时,原来的颜色就恢复了。就像在WinForms ControlPaint.DrawReversibleFrame或(旧的) Windows FocusRects中。
我使用的是SkiaSharp 2.88.0
发布于 2022-12-03 11:12:34
绘图时可以使用排除混合模式,例如:
// draw some random image on canvas
var bitmap = SKBitmap.Decode(@"random.jpg");
var info = new SKImageInfo(256, 256);
using var surf = SKSurface.Create(info);
var canvas = surf.Canvas;
canvas.DrawBitmap(bitmap, info.Rect);
// initialize paint with Exclusion blend mode
var paint = new SKPaint {
Color = SKColors.Yellow,
Style = SKPaintStyle.Fill,
BlendMode = SKBlendMode.Exclusion
};
// draw overlapping rectangles using the paint
canvas.DrawRect(10, 10, 50, 50, paint);
canvas.DrawRect(25, 25, 50, 50, paint);结果图像:

https://stackoverflow.com/questions/72522380
复制相似问题