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);
            }
        }
 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;
 }
示例#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);
        }
示例#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);
        }
示例#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);
 }
示例#8
0
 public Path(SKPath path, SKStrokeCap cap, SKStrokeJoin join)
 {
     source    = path;
     this.cap  = cap;
     this.join = join;
 }
示例#9
0
 public extern static void sk_paint_set_stroke_join(sk_paint_t t, SKStrokeJoin join);
示例#10
0
 public Icon(SKPath path, SKStrokeCap cap, SKStrokeJoin join)
 {
     this.Path = path;
     this.Cap  = cap;
     this.Join = join;
 }
示例#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);
     }
 }
示例#12
0
		public extern static void sk_paint_set_stroke_join(sk_paint_t t, SKStrokeJoin join);
        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);
            }
        }
示例#14
0
 public void SetFixStrokeJoin(SKStrokeJoin join)
 {
     variableStrokeJoin = false;
     paint.StrokeJoin   = join;
 }
        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;
            }
        }
示例#16
0
 public void UpdateStrokeLineJoin(SKStrokeJoin strokeJoin)
 {
     _skPaint.StrokeJoin = strokeJoin;
     _skCanvasView.Invalidate();
 }
 public void Stroke(SKCanvas canvas, SKPath path, float size, StrokeStyle style, SKStrokeCap cap, SKStrokeJoin join)
 {
     throw new NotImplementedException();
 }