Esempio n. 1
0
        /// <summary>
        /// Sets the color range of this particle type.
        /// </summary>
        /// <param name="start">The starting color.</param>
        /// <param name="finish">The finish color.</param>
        /// <param name="ease">Optional easer function.</param>
        /// <returns>This ParticleType object.</returns>
        public ParticleType SetColor(Color start, Color finish, Emitter.Easer ease = null)
        {
            uint s = FP.HexColor(start);
            uint f = FP.HexColor(finish);

            s          &= 0xFFFFFF;
            f          &= 0xFFFFFF;
            _red        = (s >> 16 & 0xFF) / 255.0f;
            _green      = (s >> 8 & 0xFF) / 255.0f;
            _blue       = (s & 0xFF) / 255.0f;
            _redRange   = (f >> 16 & 0xFF) / 255.0f - _red;
            _greenRange = (f >> 8 & 0xFF) / 255.0f - _green;
            _blueRange  = (f & 0xFF) / 255.0f - _blue;

            _colorEase = ease;
            return(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Tweens the color to a new color.
        /// </summary>
        /// <param name="duration">Duration of the tween.</param>
        /// <param name="fromColor"></param>
        /// <param name="toColor">Start color.</param>
        /// <param name="ease">Optional easer function.</param>
        public void tween(float duration, Color fromColor, Color toColor, Easer ease = null)
        {
            Color = fromColor;
            uint from = FP.HexColor(fromColor);
            uint to   = FP.HexColor(toColor);

            _startR = FP.GetRed(from);
            _startG = FP.GetGreen(from);
            _startB = FP.GetBlue(from);

            _rangeR = FP.GetRed(to) - _startR;
            _rangeG = FP.GetGreen(to) - _startG;
            _rangeB = FP.GetBlue(to) - _startB;

            _target = duration;
            _ease   = ease;
            Start();
        }