internal BaseStrokeContent(LottieDrawable lottieDrawable, BaseLayer layer, CanvasCapStyle cap, CanvasLineJoin join, float miterLimit, AnimatableIntegerValue opacity, AnimatableFloatValue width, List <AnimatableFloatValue> dashPattern, AnimatableFloatValue offset) { _lottieDrawable = lottieDrawable; _layer = layer; Paint.Style = Paint.PaintStyle.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; } }
/// <summary> /// Turn into pen line cap. /// </summary> /// <param name="cap"> The cap. </param> /// <returns> The product cap. </returns> public static PenLineCap ToPenLineCap(this CanvasCapStyle cap) { switch (cap) { case CanvasCapStyle.Flat: return(PenLineCap.Flat); case CanvasCapStyle.Square: return(PenLineCap.Square); case CanvasCapStyle.Round: return(PenLineCap.Round); case CanvasCapStyle.Triangle: return(PenLineCap.Triangle); default: return(PenLineCap.Flat); } }
// Cap private void ConstructCap() { this.CapSegmented.CapChanged += (s, cap) => { CanvasCapStyle strokeStyleCap = cap; this.SelectionViewModel.StrokeStyle_Cap = strokeStyleCap; this.MethodViewModel.ILayerChanged <CanvasCapStyle> ( set: (layer) => { layer.Style.StrokeStyle.DashCap = strokeStyleCap; layer.Style.StrokeStyle.StartCap = strokeStyleCap; layer.Style.StrokeStyle.EndCap = strokeStyleCap; this.SelectionViewModel.StandardStyleLayer = layer; }, type: HistoryType.LayersProperty_SetStyle_StrokeStyle_Cap, getUndo: (layer) => layer.Style.StrokeStyle.DashCap, setUndo: (layer, previous) => layer.Style.StrokeStyle.DashCap = previous ); }; }