internal ContentGroup(LottieDrawable lottieDrawable, BaseLayer layer, string name, List <IContent> contents, AnimatableTransform transform) { Name = name; _contents = contents; if (transform != null) { _transformAnimation = transform.CreateAnimation(); _transformAnimation.AddAnimationsToLayer(layer); _transformAnimation.ValueChanged += (sender, args) => { lottieDrawable.InvalidateSelf(); }; } var greedyContents = new List <IGreedyContent>(); for (var i = contents.Count - 1; i >= 0; i--) { var content = contents[i]; if (content is IGreedyContent greedyContent) { greedyContents.Add(greedyContent); } } for (var i = greedyContents.Count - 1; i >= 0; i--) { greedyContents[i].AbsorbContent(_contents); } }
internal RepeaterContent(LottieDrawable lottieDrawable, BaseLayer layer, Repeater repeater) { _lottieDrawable = lottieDrawable; _layer = layer; Name = repeater.Name; _copies = repeater.Copies.CreateAnimation(); layer.AddAnimation(_copies); _copies.ValueChanged += OnValueChanged; _offset = repeater.Offset.CreateAnimation(); layer.AddAnimation(_offset); _offset.ValueChanged += OnValueChanged; _transform = repeater.Transform.CreateAnimation(); _transform.AddAnimationsToLayer(layer); _transform.ValueChanged += OnValueChanged; }
public PuppetPart(int id, string name, Frame frame, Puppet puppet) : base(name, frame) { _id = id; _puppet = puppet; _tAnimation = new TransformKeyframeAnimation(puppet.AnimManager); _tAnimation.Apply = (v) => { SetPosition(v.x, v.y); SetRotation(v.rotation); SetScale(v.scaleX, v.scaleY); }; _cAnimation = new ColorKeyframeAnimation(puppet.AnimManager); _cAnimation.Apply = (v) => { SetTint(v); }; _oAnimation = new Vector2KeyframeAnimation(puppet.AnimManager); _oAnimation.Apply = (v) => { Origin = v; }; }
internal BaseLayer(ILottieDrawable lottieDrawable, Layer layerModel) { LottieDrawable = lottieDrawable; LayerModel = layerModel; _drawTraceName = layerModel.Name + ".Draw"; _contentPaint.SetAlpha(255); _clearPaint.BlendMode = SKBlendMode.Clear; _addMaskPaint.BlendMode = SKBlendMode.DstIn; _addMaskPaint.Color = SKColors.Black; _subtractMaskPaint.BlendMode = SKBlendMode.DstOut; _subtractMaskPaint.Color = SKColors.Black; if (layerModel.GetMatteType() == Layer.MatteType.Invert) { _mattePaint.BlendMode = SKBlendMode.DstOut; } else { _mattePaint.BlendMode = SKBlendMode.DstIn; } _mattePaint.Color = SKColors.Black; Transform = layerModel.Transform.CreateAnimation(); Transform.ValueChanged += OnValueChanged; if (layerModel.Masks != null && layerModel.Masks.Count > 0) { _mask = new MaskKeyframeAnimation(layerModel.Masks); foreach (var animation in _mask.MaskAnimations) { // Don't call AddAnimation() because progress gets set manually in setProgress to // properly handle time scale. animation.ValueChanged += OnValueChanged; } foreach (var animation in _mask.OpacityAnimations) { AddAnimation(animation); animation.ValueChanged += OnValueChanged; } } SetupInOutAnimations(); }
internal BaseLayer(LottieDrawable lottieDrawable, Layer layerModel) { LottieDrawable = lottieDrawable; LayerModel = layerModel; _drawTraceName = layerModel.Name + ".Draw"; _contentPaint.Alpha = 255; _clearPaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.Clear); _addMaskPaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.DstIn); _subtractMaskPaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.DstOut); if (layerModel.GetMatteType() == Layer.MatteType.Invert) { _mattePaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.DstOut); } else { _mattePaint.Xfermode = new PorterDuffXfermode(PorterDuff.Mode.DstIn); } Transform = layerModel.Transform.CreateAnimation(); Transform.ValueChanged += OnValueChanged; if (layerModel.Masks != null && layerModel.Masks.Count > 0) { _mask = new MaskKeyframeAnimation(layerModel.Masks); foreach (var animation in _mask.MaskAnimations) { AddAnimation(animation); animation.ValueChanged += OnValueChanged; } foreach (var animation in _mask.OpacityAnimations) { AddAnimation(animation); animation.ValueChanged += OnValueChanged; } } SetupInOutAnimations(); }