Example #1
0
        public void Draw(LayerModel layerModel, DrawingContext c)
        {
            // If an animation is present, let it handle the drawing
            if (layerModel.LayerAnimation != null && !(layerModel.LayerAnimation is NoneAnimation))
            {
                layerModel.LayerAnimation.Draw(layerModel, c, DrawScale);
                return;
            }

            // Otherwise draw the rectangle with its layer.AppliedProperties dimensions and brush
            var rect = layerModel.Properties.Contain
                ? layerModel.LayerRect()
                : new Rect(layerModel.Properties.X * 4, layerModel.Properties.Y * 4,
                           layerModel.Properties.Width * 4, layerModel.Properties.Height * 4);

            var clip = layerModel.LayerRect(DrawScale);

            // Can't meddle with the original brush because it's frozen.
            var brush = layerModel.Brush.Clone();

            brush.Opacity = layerModel.Opacity;

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(brush, null, rect);
            c.Pop();
        }
Example #2
0
        public void Draw(LayerModel layerModel, DrawingContext c)
        {
            ConicalBrushPropertiesModel properties = layerModel.Properties as ConicalBrushPropertiesModel;

            if (properties == null)
            {
                return;
            }

            Brush origBrush = layerModel.Brush;

            _conicalGradientDrawer.GradientStops = GetGradientStops(layerModel.Brush).Select(x => new Tuple <double, Color>(x.Offset, x.Color)).ToList();
            _conicalGradientDrawer.Update();
            layerModel.Brush = _conicalGradientDrawer.Brush;

            // If an animation is present, let it handle the drawing
            if (layerModel.LayerAnimation != null && !(layerModel.LayerAnimation is NoneAnimation))
            {
                layerModel.LayerAnimation.Draw(layerModel, c, DrawScale);
                return;
            }

            // Otherwise draw the rectangle with its layer.AppliedProperties dimensions and brush
            Rect rect = layerModel.Properties.Contain
                ? layerModel.LayerRect(DrawScale)
                : new Rect(layerModel.Properties.X * DrawScale, layerModel.Properties.Y * DrawScale,
                           layerModel.Properties.Width * DrawScale, layerModel.Properties.Height * DrawScale);

            Rect clip = layerModel.LayerRect();

            // Can't meddle with the original brush because it's frozen.
            Brush brush = layerModel.Brush.Clone();

            brush.Opacity = layerModel.Opacity;

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(brush, null, rect);
            c.Pop();

            layerModel.Brush = origBrush;
        }
Example #3
0
        public void Draw(LayerModel layerModel, DrawingContext c, int drawScale)
        {
            if (layerModel.Brush == null)
            {
                return;
            }

            // Set up variables for this frame
            var rect = layerModel.Properties.Contain
                ? layerModel.LayerRect(drawScale)
                : layerModel.Properties.PropertiesRect(drawScale);

            var clip = layerModel.LayerRect(drawScale);

            // Take an offset of 4 to allow layers to slightly leave their bounds
            var progress = (6.0 - layerModel.AnimationProgress) * 10.0;

            if (progress < 0)
            {
                // Can't meddle with the original brush because it's frozen.
                var brush = layerModel.Brush.Clone();
                brush.Opacity = 1 + 0.025 * progress;
                if (brush.Opacity < 0)
                {
                    brush.Opacity = 0;
                }
                if (brush.Opacity > 1)
                {
                    brush.Opacity = 1;
                }
                layerModel.Brush = brush;
            }
            rect.Inflate(-rect.Width / 100.0 * progress, -rect.Height / 100.0 * progress);
            clip.Inflate(-clip.Width / 100.0 * progress, -clip.Height / 100.0 * progress);

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(layerModel.Brush, null, rect);
            c.Pop();
        }
Example #4
0
        public void Draw(LayerModel layerModel, DrawingContext c, int drawScale)
        {
            if (layerModel.Brush == null)
            {
                return;
            }

            // Set up variables for this frame
            var rect = layerModel.Properties.Contain
                ? layerModel.LayerRect(drawScale)
                : layerModel.Properties.PropertiesRect(drawScale);

            var s1 = new Rect(new Point(rect.X, rect.Y - layerModel.AnimationProgress),
                              new Size(rect.Width, rect.Height + .5));
            var s2 = new Rect(new Point(s1.X, s1.Y + rect.Height), new Size(rect.Width, rect.Height));

            var clip = layerModel.LayerRect(drawScale);

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(layerModel.Brush, null, s1);
            c.DrawRectangle(layerModel.Brush, null, s2);
            c.Pop();
        }
Example #5
0
        public void Draw(LayerModel layerModel, DrawingContext c, int drawScale)
        {
            if (layerModel.Brush == null || _opacityTweener == null)
            {
                return;
            }

            // Set up variables for this frame
            var rect = layerModel.Properties.Contain
                ? layerModel.LayerRect(drawScale)
                : layerModel.Properties.PropertiesRect(drawScale);

            var clip = layerModel.LayerRect(drawScale);

            // Can't meddle with the original brush because it's frozen.
            var brush = layerModel.Brush.Clone();

            brush.Opacity    = _opacityTweener.Value / 1000;
            layerModel.Brush = brush;

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(layerModel.Brush, null, rect);
            c.Pop();
        }
Example #6
0
        public void Draw(LayerModel layerModel, DrawingContext c, int drawScale)
        {
            if (layerModel.Brush == null)
            {
                return;
            }

            // Set up variables for this frame
            var rect = layerModel.Properties.Contain
                ? layerModel.LayerRect(drawScale)
                : layerModel.Properties.PropertiesRect(drawScale);

            var clip = layerModel.LayerRect(drawScale);

            // Can't meddle with the original brush because it's frozen.
            var brush = layerModel.Brush.Clone();

            brush.Opacity    = (Math.Sin(layerModel.AnimationProgress * Math.PI) + 1) * (layerModel.Opacity / 2);
            layerModel.Brush = brush;

            c.PushClip(new RectangleGeometry(clip));
            c.DrawRectangle(layerModel.Brush, null, rect);
            c.Pop();
        }
Example #7
0
        public void Draw(LayerModel layerModel, DrawingContext c, int drawScale)
        {
            if (layerModel.Brush == null)
            {
                return;
            }

            // Set up variables for this frame
            var fillRect = layerModel.Properties.PropertiesRect(drawScale);
            var fillSize = Math.Sqrt(fillRect.Width * fillRect.Width + fillRect.Height * fillRect.Height);

            fillRect.Inflate(fillSize - fillRect.Width, fillSize - fillRect.Height);

            var clip = layerModel.LayerRect(drawScale);

            c.PushClip(new RectangleGeometry(clip));
            c.PushTransform(new RotateTransform(36 * layerModel.AnimationProgress, fillRect.X + fillRect.Width / 2, fillRect.Y + fillRect.Height / 2));
            c.DrawRectangle(layerModel.Brush, null, fillRect);
            c.Pop();
            c.Pop();
        }
Example #8
0
        public void Draw(LayerModel layerModel, DrawingContext c)
        {
            var rect = layerModel.LayerRect(DrawScale);

            c.DrawRectangle(((AmbientLightPropertiesModel)layerModel.Properties).AmbientLightBrush, null, rect);
        }