xamarin 使用SkiaSharp时SKColorFilter.CreateBlendMode是否可以创建虚线?

ldfqzlk8  于 2022-12-07  发布在  其他
关注(0)|答案(1)|浏览(201)

我使用CreateBlendMode更改SVG绘图的颜色,如下所示:

public Color TintColor;
TintColor = Colors.LawnGreen;

using (var paint = new SKPaint())
{
   paint.ColorFilter = SKColorFilter.CreateBlendMode(SKColor.Parse(TintColor.ToHex()), 
   SKBlendMode.SrcIn);
   canvas.DrawPicture(Picture, position.X, position.Y, paint);
}

图像之前

之后的图像

但是我需要像下一张图片一样把线划成虚线。这可能吗?

h9a6wy2h

h9a6wy2h1#

是的。只要设置你正在使用的绘画的路径效果。
示例:

SKPaint paint = new SKPaint();
paint.Style = SKPaintStyle.Stroke;
paint.StrokeWidth = 1.5f;
SKRect rect = new SKRect(_MouseDownPt.X, _MouseDownPt.Y, _MouseMovePt.X, _MouseMovePt.Y);
paint.PathEffect = SKPathEffect.CreateDash(new float[] {10,6},0);
paint.Color = new SKColor(0xaa,0x40,0);
paint.BlendMode = SKBlendMode.ColorDodge;
canvas.DrawRect(rect,paint);

相关问题