private void StrokeSkiaPath(SKPath skPath, IShape shape)
        {
            IBrush?stroke = shape.Stroke;

            if (stroke != null)
            {
                using SKPaint paint = new SKPaint { Style = SKPaintStyle.Stroke, IsAntialias = true };
                InitSkiaPaintForBrush(paint, stroke, shape);
                paint.StrokeWidth = (int)shape.StrokeThickness;
                paint.StrokeMiter = (float)shape.StrokeMiterLimit;

                SKStrokeCap strokeCap = shape.StrokeLineCap switch
                {
                    PenLineCap.Flat => SKStrokeCap.Butt,
                    PenLineCap.Round => SKStrokeCap.Round,
                    PenLineCap.Square => SKStrokeCap.Square,
                    _ => throw new InvalidOperationException($"Unknown PenLineCap value {shape.StrokeLineCap}")
                };
                paint.StrokeCap = strokeCap;

                SKStrokeJoin strokeJoin = shape.StrokeLineJoin switch
                {
                    PenLineJoin.Miter => SKStrokeJoin.Miter,
                    PenLineJoin.Bevel => SKStrokeJoin.Bevel,
                    PenLineJoin.Round => SKStrokeJoin.Round,
                    _ => throw new InvalidOperationException($"Unknown PenLineJoin value {shape.StrokeLineJoin}")
                };
                paint.StrokeJoin = strokeJoin;

                _skCanvas.DrawPath(skPath, paint);
            }
        }
Exemplo n.º 2
0
 public Stroke(float size, IBrush brush, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join)
 {
     this.Size  = size;
     this.Brush = brush;
     this.Style = style;
     this.Cap   = cap;
     this.Join  = join;
 }
Exemplo n.º 3
0
        public static AM.PenLineJoin ToPenLineJoin(this SKStrokeJoin strokeJoin)
        {
            switch (strokeJoin)
            {
            default:
            case SKStrokeJoin.Miter:
                return(AM.PenLineJoin.Miter);

            case SKStrokeJoin.Round:
                return(AM.PenLineJoin.Round);

            case SKStrokeJoin.Bevel:
                return(AM.PenLineJoin.Bevel);
            }
        }
        public static PenLineJoin ToCommon(this SKStrokeJoin skStrokeCap)
        {
            PenLineJoin penLineCap = PenLineJoin.Miter;

            switch (skStrokeCap)
            {
            case SKStrokeJoin.Miter:
                penLineCap = PenLineJoin.Miter;
                break;

            case SKStrokeJoin.Bevel:
                penLineCap = PenLineJoin.Bevel;
                break;

            case SKStrokeJoin.Round:
                penLineCap = PenLineJoin.Round;
                break;
            }
            return(penLineCap);
        }
        public static SKStrokeJoin ToSkia(this PenLineJoin penLineCap)
        {
            SKStrokeJoin skStrokeJoin = SKStrokeJoin.Miter;

            switch (penLineCap)
            {
            case PenLineJoin.Miter:
                skStrokeJoin = SKStrokeJoin.Miter;
                break;

            case PenLineJoin.Bevel:
                skStrokeJoin = SKStrokeJoin.Bevel;
                break;

            case PenLineJoin.Round:
                skStrokeJoin = SKStrokeJoin.Round;
                break;
            }
            return(skStrokeJoin);
        }
Exemplo n.º 6
0
        void UpdateStrokeLineJoin()
        {
            PenLineJoin  lineJoin     = Element.StrokeLineJoin;
            SKStrokeJoin skStrokeJoin = SKStrokeJoin.Miter;

            switch (lineJoin)
            {
            case PenLineJoin.Miter:
                skStrokeJoin = SKStrokeJoin.Miter;
                break;

            case PenLineJoin.Bevel:
                skStrokeJoin = SKStrokeJoin.Bevel;
                break;

            case PenLineJoin.Round:
                skStrokeJoin = SKStrokeJoin.Round;
                break;
            }
            Control.UpdateStrokeLineJoin(skStrokeJoin);
        }
Exemplo n.º 7
0
 public static CGLineJoin LineJoin(SKStrokeJoin join)
 {
     return((join == SKStrokeJoin.Round) ? CGLineJoin.Round : (join == SKStrokeJoin.Bevel) ? CGLineJoin.Bevel : (join == SKStrokeJoin.Miter) ? CGLineJoin.Miter : 0);
 }
Exemplo n.º 8
0
 public Path(SKPath path, SKStrokeCap cap, SKStrokeJoin join)
 {
     source    = path;
     this.cap  = cap;
     this.join = join;
 }
Exemplo n.º 9
0
 public extern static void sk_paint_set_stroke_join(sk_paint_t t, SKStrokeJoin join);
Exemplo n.º 10
0
 public Icon(SKPath path, SKStrokeCap cap, SKStrokeJoin join)
 {
     this.Path = path;
     this.Cap  = cap;
     this.Join = join;
 }
Exemplo n.º 11
0
 public void Stroke(SKCanvas canvas, SKPath path, float size, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join)
 {
     using (var paint = this.CreatePaint(path))
     {
         paint.StrokeWidth = size;
         paint.StrokeCap   = cap;
         paint.StrokeJoin  = join;
         paint.Style       = SKPaintStyle.Stroke;
         canvas.DrawPath(path, paint);
     }
 }
Exemplo n.º 12
0
		public extern static void sk_paint_set_stroke_join(sk_paint_t t, SKStrokeJoin join);
Exemplo n.º 13
0
        public void Stroke(SKCanvas canvas, SKPath path, float size, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join)
        {
            using (var paint = new SKPaint()
            {
                IsAntialias = true,
                StrokeWidth = size,
                Color = this.Color,
                Style = SKPaintStyle.Stroke,
                StrokeCap = cap,
                StrokeJoin = join,
            })
            {
                if (style == StrokeStyle.Dotted)
                {
                    paint.PathEffect = SKPathEffect.CreateDash(new[] { 0, size * 2, 0, size * 2 }, 0);
                }
                else if (style == StrokeStyle.Dashed)
                {
                    paint.PathEffect = SKPathEffect.CreateDash(new[] { size * 6, size * 2 }, 0);
                }

                canvas.DrawPath(path, paint);
            }
        }
Exemplo n.º 14
0
 public void SetFixStrokeJoin(SKStrokeJoin join)
 {
     variableStrokeJoin = false;
     paint.StrokeJoin   = join;
 }
Exemplo n.º 15
0
        internal BaseStrokeContent(ILottieDrawable lottieDrawable, BaseLayer layer, SKStrokeCap cap, SKStrokeJoin join, float miterLimit, AnimatableIntegerValue opacity, AnimatableFloatValue width, List <AnimatableFloatValue> dashPattern, AnimatableFloatValue offset)
        {
            _lottieDrawable = lottieDrawable;
            _layer          = layer;

            Paint.Style       = SKPaintStyle.Stroke;
            Paint.StrokeCap   = cap;
            Paint.StrokeJoin  = join;
            Paint.StrokeMiter = miterLimit;

            _opacityAnimation = opacity.CreateAnimation();
            _widthAnimation   = width.CreateAnimation();

            if (offset == null)
            {
                _dashPatternOffsetAnimation = null;
            }
            else
            {
                _dashPatternOffsetAnimation = offset.CreateAnimation();
            }
            _dashPatternAnimations = new List <IBaseKeyframeAnimation <float?, float?> >(dashPattern.Count);
            _dashPatternValues     = new float[dashPattern.Count];

            for (var i = 0; i < dashPattern.Count; i++)
            {
                _dashPatternAnimations.Add(dashPattern[i].CreateAnimation());
            }

            layer.AddAnimation(_opacityAnimation);
            layer.AddAnimation(_widthAnimation);
            for (var i = 0; i < _dashPatternAnimations.Count; i++)
            {
                layer.AddAnimation(_dashPatternAnimations[i]);
            }
            if (_dashPatternOffsetAnimation != null)
            {
                layer.AddAnimation(_dashPatternOffsetAnimation);
            }

            _opacityAnimation.ValueChanged += OnValueChanged;
            _widthAnimation.ValueChanged   += OnValueChanged;

            for (var i = 0; i < dashPattern.Count; i++)
            {
                _dashPatternAnimations[i].ValueChanged += OnValueChanged;
            }
            if (_dashPatternOffsetAnimation != null)
            {
                _dashPatternOffsetAnimation.ValueChanged += OnValueChanged;
            }
        }
Exemplo n.º 16
0
 public void UpdateStrokeLineJoin(SKStrokeJoin strokeJoin)
 {
     _skPaint.StrokeJoin = strokeJoin;
     _skCanvasView.Invalidate();
 }
Exemplo n.º 17
0
 public void Stroke(SKCanvas canvas, SKPath path, float size, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join)
 {
     throw new NotImplementedException();
 }