Beispiel #1
0
        public static ColorMap Hot(int size)
        {
            ColorMap map = new ColorMap(size);
            float v, step = 1.0f / (size - 1);
            float[] rgb = new float[3];

            for (int i = 0; i < size; i += 1)
            {
                v = 2.5f * i * step;

				rgb[0] = v;
				rgb[1] = v - 1;
				rgb[2] = 2 * v - 4;

                Clamp(rgb, 0.0f, 1.0f);

                map.colors[i] = ColorFromRgb(rgb[0], rgb[1], rgb[2]);
            }

            return map;
        }
Beispiel #2
0
        public static ColorMap Jet(int size)
        {
            ColorMap map = new ColorMap(size);
            float v, step = 1.0f / (size - 1);
            float[] rgb = new float[3];

            for (int i = 0; i < size; i += 1)
            {
                v = 4 * i * step;

				rgb[0] = Math.Min(v - 1.5f, 4.5f - v);
				rgb[1] = Math.Min(v - 0.5f, 3.5f - v);
				rgb[2] = Math.Min(v + 0.5f, 2.5f - v);

                Clamp(rgb, 0.0f, 1.0f);

                map.colors[size - i - 1] = ColorFromRgb(rgb[0], rgb[1], rgb[2]);
            }

            return map;
        }
Beispiel #3
0
        public static ColorMap Jet(int size)
        {
            ColorMap map = new ColorMap(size);
            float    v, step = 1.0f / (size - 1);

            float[] rgb = new float[3];

            for (int i = 0; i < size; i += 1)
            {
                v = 4 * i * step;

                rgb[0] = Math.Min(v - 1.5f, 4.5f - v);
                rgb[1] = Math.Min(v - 0.5f, 3.5f - v);
                rgb[2] = Math.Min(v + 0.5f, 2.5f - v);

                Clamp(rgb, 0.0f, 1.0f);

                map.colors[size - i - 1] = ColorFromRgb(rgb[0], rgb[1], rgb[2]);
            }

            return(map);
        }
Beispiel #4
0
        public static ColorMap Hot(int size)
        {
            ColorMap map = new ColorMap(size);
            float    v, step = 1.0f / (size - 1);

            float[] rgb = new float[3];

            for (int i = 0; i < size; i += 1)
            {
                v = 2.5f * i * step;

                rgb[0] = v;
                rgb[1] = v - 1;
                rgb[2] = 2 * v - 4;

                Clamp(rgb, 0.0f, 1.0f);

                map.colors[i] = ColorFromRgb(rgb[0], rgb[1], rgb[2]);
            }

            return(map);
        }
        // TODO: remove colormap argument
        public void AttachLayerData(float[] values, ColorMap colormap)
        {
            int length = values.Length;

            Color[] data = new Color[length];

            double min = double.MaxValue;
            double max = double.MinValue;

            // Find min and max of given values.
            for (int i = 0; i < length; i++)
            {
                if (values[i] < min)
                {
                    min = values[i];
                }

                if (values[i] > max)
                {
                    max = values[i];
                }
            }

            for (int i = 0; i < length; i++)
            {
                data[i] = colormap.GetColor(values[i], min, max);
            }

            colors = new ColorBuffer(data, 1);
        }