using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;

namespace Performance.Infrastructure
{
    public class RandomHelper
    {
        /// <summary>
        /// 四位验证码
        /// </summary>
        /// <returns></returns>
        public static string GetSmsCode()
        {
            Random rad = new Random(Guid.NewGuid().GetHashCode());
            var code = rad.Next(1000, 10000);

            return code.ToString().PadLeft(4, '0');
        }

        public static List<Color> Color(Color sColor, Color eColor, int number)
        {
            int sr = sColor.R;
            int sg = sColor.G;
            int sb = sColor.B;

            int er = eColor.R;
            int eg = eColor.G;
            int eb = eColor.B;

            var colorList = new List<Color>();
            for (int i = 0; i < number; i++)
            {
                var rAverage = sr + (int)((er - sr) * i / number);
                var gAverage = sg + (int)((eg - sg) * i / number);
                var bAverage = sb + (int)((eb - sb) * i / number);
                colorList.Add(System.Drawing.Color.FromArgb(rAverage, gAverage, bAverage));
            }
            return colorList;
        }
    }
}
