Artemis.Profiles.Layers.Animations.PulseAnimation.Draw C# (CSharp) Method

Draw() public method

public Draw ( LayerPropertiesModel props, LayerPropertiesModel applied, System.Windows.Media.DrawingContext c ) : void
props Artemis.Profiles.Layers.Models.LayerPropertiesModel
applied Artemis.Profiles.Layers.Models.LayerPropertiesModel
c System.Windows.Media.DrawingContext
return void
        public void Draw(LayerPropertiesModel props, LayerPropertiesModel applied, DrawingContext c)
        {
            if (applied.Brush == null)
                return;

            const int scale = 4;
            // Set up variables for this frame
            var rect = props.Contain
                ? new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale)
                : new Rect(props.X*scale, props.Y*scale, props.Width*scale, props.Height*scale);

            var clip = new Rect(applied.X*scale, applied.Y*scale, applied.Width*scale, applied.Height*scale);

            // Can't meddle with the original brush because it's frozen.
            var brush = applied.Brush.Clone();
            brush.Opacity = (Math.Sin(props.AnimationProgress*Math.PI) + 1)*(props.Opacity/2);
            applied.Brush = brush;

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(applied.Brush, null, rect);
            c.Pop();
        }