Ejemplo n.º 1
0
 public bool Equals(AnimationFrame p)
 {
     return(_color.Equals(p._color) &&
            _dimension.Equals(p._dimension) &&
            _width.Equals(p._width) &&
            _duration.Equals(p._duration));
 }
Ejemplo n.º 2
0
        public void SetFrame(float time, AnimationFrame animframe)
        {
            if (time > _animationDuration)
            {
                _animationDuration = time;
            }

            _animations[time] = animframe;
        }
Ejemplo n.º 3
0
        public AnimationTrack SetFrame(float time, AnimationFrame animframe)
        {
            if (time > _animationDuration)
            {
                _animationDuration = time;
            }

            _animations[time] = animframe;

            return(this);
        }
Ejemplo n.º 4
0
        public AnimationTrack RemoveFrame(AnimationFrame frame)
        {
            foreach (KeyValuePair <float, AnimationFrame> kvp in _animations)
            {
                if (kvp.Value.Equals(frame))
                {
                    _animations.Remove(kvp.Key);
                    break;
                }
            }

            UpdateDuration();
            return(this);
        }
Ejemplo n.º 5
0
        public virtual AnimationFrame GetCopy()
        {
            RectangleF newrect = new RectangleF(_dimension.X,
                                                _dimension.Y,
                                                _dimension.Width,
                                                _dimension.Height
                                                );

            AnimationFrame copy = new AnimationFrame();

            copy._dimension = newrect;
            copy._color     = Color.FromArgb(_color.A, _color.R, _color.G, _color.B);

            return(copy);
        }
Ejemplo n.º 6
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationFilledRectangle))
            {
                throw new FormatException("Cannot blend with another type");
            }

            Rectangle newrect = new Rectangle((int)(_dimension_int.X * (1.0 - amount) + (otherAnim as AnimationFilledRectangle)._dimension_int.X * (amount)),
                                              (int)(_dimension_int.Y * (1.0 - amount) + (otherAnim as AnimationFilledRectangle)._dimension_int.Y * (amount)),
                                              (int)(_dimension_int.Width * (1.0 - amount) + (otherAnim as AnimationFilledRectangle)._dimension_int.Width * (amount)),
                                              (int)(_dimension_int.Height * (1.0 - amount) + (otherAnim as AnimationFilledRectangle)._dimension_int.Height * (amount))
                                              );

            return(new AnimationFilledRectangle(newrect, Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount)));
        }
Ejemplo n.º 7
0
        public virtual AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            RectangleF newrect = new RectangleF((float)(_dimension.X * (1.0 - amount) + otherAnim._dimension.X * (amount)),
                                                (float)(_dimension.Y * (1.0 - amount) + otherAnim._dimension.Y * (amount)),
                                                (float)(_dimension.Width * (1.0 - amount) + otherAnim._dimension.Width * (amount)),
                                                (float)(_dimension.Height * (1.0 - amount) + otherAnim._dimension.Height * (amount))
                                                );


            AnimationFrame newframe = new AnimationFrame();

            newframe._dimension = newrect;
            newframe._color     = Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount);

            return(newframe);
        }
Ejemplo n.º 8
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationFill))
            {
                throw new FormatException("Cannot blend with another type");
            }

            if (_transitionType == AnimationFrameTransitionType.None)
            {
                return(new AnimationFill(Color.Transparent));
            }

            amount = GetTransitionValue(amount);

            return(new AnimationFill(Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount)));
        }
Ejemplo n.º 9
0
        public virtual AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            amount = GetTransitionValue(amount);

            RectangleF newrect = new RectangleF((float)CalculateNewValue(_dimension.X, otherAnim._dimension.X, amount),
                                                (float)CalculateNewValue(_dimension.Y, otherAnim._dimension.Y, amount),
                                                (float)CalculateNewValue(_dimension.Width, otherAnim._dimension.Width, amount),
                                                (float)CalculateNewValue(_dimension.Height, otherAnim._dimension.Height, amount)
                                                );

            AnimationFrame newframe = new AnimationFrame();

            newframe._dimension = newrect;
            newframe._color     = Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount);

            return(newframe);
        }
Ejemplo n.º 10
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationCircle))
            {
                throw new FormatException("Cannot blend with another type");
            }

            RectangleF newrect = new RectangleF((float)(_dimension.X * (1.0 - amount) + otherAnim._dimension.X * (amount)),
                                                (float)(_dimension.Y * (1.0 - amount) + otherAnim._dimension.Y * (amount)),
                                                (float)(_dimension.Width * (1.0 - amount) + otherAnim._dimension.Width * (amount)),
                                                (float)(_dimension.Height * (1.0 - amount) + otherAnim._dimension.Height * (amount))
                                                );

            int newwidth = (int)((_width * (1.0 - amount)) + (otherAnim._width * (amount)));

            return(new AnimationCircle(newrect, Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount), newwidth));
        }
Ejemplo n.º 11
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationFilledGradientRectangle))
            {
                throw new FormatException("Cannot blend with another type");
            }

            amount = GetTransitionValue(amount);

            RectangleF newrect = new RectangleF((float)CalculateNewValue(_dimension.X, otherAnim._dimension.X, amount),
                                                (float)CalculateNewValue(_dimension.Y, otherAnim._dimension.Y, amount),
                                                (float)CalculateNewValue(_dimension.Width, otherAnim._dimension.Width, amount),
                                                (float)CalculateNewValue(_dimension.Height, otherAnim._dimension.Height, amount)
                                                );

            float newAngle = (float)CalculateNewValue(_angle, otherAnim._angle, amount);

            return(new AnimationFilledGradientRectangle(newrect, _gradientBrush.BlendEffectBrush((otherAnim as AnimationFilledGradientRectangle)._gradientBrush, amount)).SetAngle(newAngle));
        }
Ejemplo n.º 12
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationFilledCircle))
            {
                throw new FormatException("Cannot blend with another type");
            }

            amount = GetTransitionValue(amount);

            RectangleF newrect = new RectangleF((float)CalculateNewValue(_dimension.X, otherAnim._dimension.X, amount),
                                                (float)CalculateNewValue(_dimension.Y, otherAnim._dimension.Y, amount),
                                                (float)CalculateNewValue(_dimension.Width, otherAnim._dimension.Width, amount),
                                                (float)CalculateNewValue(_dimension.Height, otherAnim._dimension.Height, amount)
                                                );

            float newAngle = (float)CalculateNewValue(_angle, otherAnim._angle, amount);

            return(new AnimationFilledCircle(newrect, Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount)).SetAngle(newAngle));
        }
Ejemplo n.º 13
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationLine))
            {
                throw new FormatException("Cannot blend with another type");
            }

            PointF newstart = new PointF((float)(_start_point.X * (1.0 - amount) + (otherAnim as AnimationLine)._start_point.X * (amount)),
                                         (float)(_start_point.Y * (1.0 - amount) + (otherAnim as AnimationLine)._start_point.Y * (amount))
                                         );

            PointF newend = new PointF((float)(_end_point.X * (1.0 - amount) + (otherAnim as AnimationLine)._end_point.X * (amount)),
                                       (float)(_end_point.Y * (1.0 - amount) + (otherAnim as AnimationLine)._end_point.Y * (amount))
                                       );

            int newwidth = (int)Math.Round((_width * (1.0 - amount)) + (otherAnim._width * (amount)));

            return(new AnimationLine(newstart, newend, Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount), Utils.ColorUtils.BlendColors(_end_color, (otherAnim as AnimationLine)._end_color, amount), newwidth));
        }
Ejemplo n.º 14
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationLines))
            {
                throw new FormatException("Cannot blend with another type");
            }

            if (this._lines.Count != (otherAnim as AnimationLines)._lines.Count)
            {
                throw new NotImplementedException();
            }

            List <AnimationLine> newlines = new List <AnimationLine>();

            for (int line_i = 0; line_i < this._lines.Count; line_i++)
            {
                newlines.Add(this._lines[line_i].BlendWith((otherAnim as AnimationLines)._lines[line_i], amount) as AnimationLine);
            }

            return(new AnimationLines(newlines.ToArray()));
        }
Ejemplo n.º 15
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationLine))
            {
                throw new FormatException("Cannot blend with another type");
            }

            amount = GetTransitionValue(amount);

            PointF newstart = new PointF((float)CalculateNewValue(_start_point.X, (otherAnim as AnimationLine)._start_point.X, amount),
                                         (float)CalculateNewValue(_start_point.Y, (otherAnim as AnimationLine)._start_point.Y, amount)
                                         );

            PointF newend = new PointF((float)CalculateNewValue(_end_point.X, (otherAnim as AnimationLine)._end_point.X, amount),
                                       (float)CalculateNewValue(_end_point.Y, (otherAnim as AnimationLine)._end_point.Y, amount)
                                       );

            int   newwidth = (int)Math.Round(CalculateNewValue(_width, otherAnim._width, amount));
            float newAngle = (float)CalculateNewValue(_angle, otherAnim._angle, amount);

            return(new AnimationLine(newstart, newend, Utils.ColorUtils.BlendColors(_color, otherAnim._color, amount), Utils.ColorUtils.BlendColors(_end_color, (otherAnim as AnimationLine)._end_color, amount), newwidth).SetAngle(newAngle));
        }
Ejemplo n.º 16
0
        public override AnimationFrame BlendWith(AnimationFrame otherAnim, double amount)
        {
            if (!(otherAnim is AnimationManualColorFrame))
            {
                throw new FormatException("Cannot blend with another type");
            }

            Dictionary <DeviceKeys, Color> _combinedBitmapColors = new Dictionary <DeviceKeys, Color>();

            amount = GetTransitionValue(amount);

            foreach (var kvp in _BitmapColors)
            {
                if ((otherAnim as AnimationManualColorFrame)._BitmapColors.ContainsKey(kvp.Key))
                {
                    _combinedBitmapColors.Add(kvp.Key, Utils.ColorUtils.BlendColors(kvp.Value, (otherAnim as AnimationManualColorFrame)._BitmapColors[kvp.Key], amount));
                }
                else
                {
                    _combinedBitmapColors.Add(kvp.Key, Utils.ColorUtils.MultiplyColorByScalar(kvp.Value, 1.0 - amount));
                }
            }

            foreach (var kvp in (otherAnim as AnimationManualColorFrame)._BitmapColors)
            {
                if (!_BitmapColors.ContainsKey(kvp.Key))
                {
                    _combinedBitmapColors.Add(kvp.Key, Utils.ColorUtils.MultiplyColorByScalar(kvp.Value, amount));
                }
            }

            AnimationManualColorFrame newAnim = new AnimationManualColorFrame();

            newAnim._BitmapColors = _combinedBitmapColors;

            return(newAnim);
        }