简体   繁体   中英

When using SkiaSharp SKColorFilter.CreateBlendMode is it possible to create a dashed line?

I'm using CreateBlendMode to change the color of an SVG drawing as follows:

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);
}

Image before

在此处输入图像描述

Image after

在此处输入图像描述

But I need the line to be dashed like the next image. It is possible?

在此处输入图像描述

Yes it is. Just set the PathEffect of the paint you are using.

Example:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM