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(); }