private static void makeEffects(PathEffect[] e, float phase) { e [0] = null; // no effect e [1] = new CornerPathEffect(10); e [2] = new DashPathEffect(new float[] { 10, 5, 5, 5 }, phase); e [3] = new PathDashPathEffect(makePathDash(), 12, phase, PathDashPathEffect.Style.ROTATE); e [4] = new ComposePathEffect(e [2], e [1]); e [5] = new ComposePathEffect(e [3], e [1]); }
protected override void OnDraw(Canvas canvas) { base.OnDraw(canvas); var effect = new DashPathEffect(new[] { _pathLength, _pathLength }, (_pathLength - _pathLength * _progress)); _paint.SetPathEffect(effect); canvas.Save(); canvas.Translate(PaddingLeft, PaddingTop); canvas.DrawPath(Path, _paint); canvas.Restore(); }
public static void SetStrokeStyle(this Paint paint, float strokeWidth, UGStrokeStyle strokeStyle) { paint.StrokeCap = strokeStyle.LineCap.ToAGPaintCap(); paint.StrokeJoin = strokeStyle.LineJoin.ToAGPaintJoin(); paint.StrokeMiter = strokeStyle.MiterLimit; if (strokeStyle.DashStyle.Value != null) { using (var effect = new DashPathEffect( strokeStyle.DashStyle.Value.Select(v => v * strokeWidth).ToArray(), strokeStyle.DashOffset)) { paint.SetPathEffect(effect); } } }
Paint GetPenPaint(Pen pen) { var paint = new Paint(PaintFlags.AntiAlias); paint.SetStyle(Paint.Style.Stroke); paint.SetARGB(pen.Color.A, pen.Color.R, pen.Color.G, pen.Color.B); paint.StrokeWidth = (float)pen.Width; if (pen.DashPattern != null && pen.DashPattern.Any()) { var dashPathEffect = new DashPathEffect(pen.DashPattern.ToArray(), 0); paint.SetPathEffect(dashPathEffect); } return(paint); }
/// <summary> /// Enables the axis line to be drawn in dashed mode, e.g.like this /// "- - - - - -". THIS ONLY WORKS IF HARDWARE-ACCELERATION IS TURNED OFF. /// Keep in mind that hardware acceleration boosts performance. /// </summary> /// <param name="lineLength">the length of the line pieces</param> /// <param name="spaceLength">the length of space in between the pieces</param> /// <param name="phase">offset, in degrees (normally, use 0)</param> public void EnableAxisLineDashedLine(float lineLength, float spaceLength, float phase) { axisLineDashPathEffect = new DashPathEffect(new float[] { lineLength, spaceLength }, phase); }