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