Exemplo n.º 1
0
 /// <summary>
 /// Create a new instance of a ColorEffect
 /// </summary>
 /// <param name="controle">Gui controle</param>
 /// <param name="speed">Speed of the Effect</param>
 /// <param name="from">From color of the Effect</param>
 /// <param name="to">To color of the Effect</param>
 /// <param name="loop">True if effect must loop</param>
 public ColorEffect(IColorCapable control, EffectSpeedEnum speed, Color from, Color to, bool loop = false)
     : base(control, speed, loop)
 {
     this._from   = from;
     this._to     = to;
     this._amount = 0;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Apply the effect on the control
        /// </summary>
        /// <param name="gameTime">Time elpase since last update</param>
        public override void Apply(GameTime gameTime)
        {
            if (this.Control != null)
            {
                IColorCapable colorControl = (IColorCapable)this.Control;

                this._amount =
                    (colorControl.ColorIn) ?
                    MathHelper.Min(this._amount + ((float)gameTime.ElapsedGameTime.TotalSeconds * (int)Speed), 1) :
                    MathHelper.Max(this._amount - ((float)gameTime.ElapsedGameTime.TotalSeconds * (int)(Speed)), 0);

                colorControl.BackgroundColor = Color.LerpRGB(this._from, this._to, this._amount);

                if (this.Loop && colorControl.BackgroundColor.B == this._to.B && colorControl.BackgroundColor.R == this._to.R && colorControl.BackgroundColor.G == this._to.G)//if we loop and control color RGB is equal than the color reach, set color to start value
                {
                    colorControl.BackgroundColor = this._from;
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new instance of a TextColorEffect
 /// </summary>
 /// <param name="controle">Gui controle</param>
 /// <param name="speed">Speed of the Effect</param>
 /// <param name="from">From color of the Effect</param>
 /// <param name="to">To color of the Effect</param>
 /// <param name="loop">True if effect must loop</param>
 public TextColorEffect(IColorCapable control, EffectSpeedEnum speed, Color from, Color to, bool loop = false)
     : base(control, speed, from, to, loop)
 {
 }