ArduinoTest.Components.ColorManagment.Service.ColorHelper.ComputeAverageColors C# (CSharp) Method

ComputeAverageColors() public method

Gets the average of all the colors provided
public ComputeAverageColors ( IEnumerable colors ) : Color
colors IEnumerable /// The total collection of sampled colors ///
return Color
        public Color ComputeAverageColors(IEnumerable<Color> colors)
        {
            int red = 0;
            int green = 0;
            int blue = 0;
            int count = 0;

            foreach(var color in colors)
            {
                red += color.R;
                green += color.G;
                blue += color.B;
                count++;
            }

            return Color.FromArgb(red/count, green/count, blue/count);
        }