Example #1
0
        /// <summary>
        /// Get a Color based on a input value between 0 and 100
        /// </summary>
        /// <param name="value">the input value between 0 and 100</param>
        /// <returns>MyColor</returns>
        public static MyColorHSB GetREWColorPaletteValue(float value)
        {
            float       h = 0;
            const float s = 1;
            float       l = 0;

            // determine h, s and l values
            // based on a input value between 0 and 100
            if (value < 20)
            {
                h = 0.05f * value;
                l = 0.5f;
            }
            else if (value >= 20 && value < 40)
            {
                h = 0.05f * value;
                l = -0.0075f * value + 0.6499f;
            }
            else if (value >= 40 && value < 80)
            {
                h = 0.05f * value;
                l = 0.3490196f;
            }
            else if (value >= 80)
            {
                h = 0.0244f * value + 2.0189f;
                l = -0.0053f * value + 0.7699f;
            }
            // h is between 0 - 6, but can sometimes be minus
            float hue = h * 60f;

            if (hue < 0)
            {
                hue += 360;
            }

            var hslcolor = new HSBColor(hue / 360, s, l);
            var mycolor  = new MyColorHSB(hslcolor);

            return(mycolor);
        }
Example #2
0
        /// <summary>
        /// Get a Color based on a input value between 0 and 100
        /// </summary>
        /// <param name="value">the input value between 0 and 100</param>
        /// <returns>MyColor</returns>
        public static MyColorHSB GetREWColorPaletteValue(float value)
        {
            float h = 0;
            float s = 1;
            float l = 0;

            // determine h, s and l values
            // based on a input value between 0 and 100
            if (value < 20) {
                h = 0.05f * value;
                l = 0.5f;
            } else if (value >= 20 && value < 40) {
                h = 0.05f * value;
                l = -0.0075f * value + 0.6499f;
            } else if (value >= 40 && value < 80) {
                h = 0.05f * value;
                l = 0.3490196f;
            } else if (value >= 80) {
                h = 0.0244f * value + 2.0189f;
                l = -0.0053f * value + 0.7699f;
            }
            // h is between 0 - 6, but can sometimes be minus
            float hue = h * 60f;
            if (hue < 0) hue += 360;

            HSBColor hslcolor = new HSBColor(hue/360, s, l);
            MyColorHSB mycolor = new MyColorHSB(hslcolor);
            return mycolor;
        }