Esempio n. 1
0
 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 {
     return(List.GetEnumerator());
 }
Esempio n. 2
0
            public byte[] Create(int size)
            {
                byte[] colorMap = new byte[size * 4];
                float  x_delta  = x_max - x_min;

                System.Collections.Generic.IEnumerator <System.Collections.Generic.KeyValuePair <float, Vector4> > iter = samples.GetEnumerator();
                if (!iter.MoveNext())
                {
                    return(null);                    // No samples provided
                }
                System.Collections.Generic.KeyValuePair <float, Vector4> lastSample = iter.Current;
                while (iter.MoveNext())
                {
                    System.Collections.Generic.KeyValuePair <float, Vector4> currentSample = iter.Current;

                    float lastX = (lastSample.Key - x_min) / x_delta, currentX = (currentSample.Key - x_min) / x_delta;
                    int   lastIdx = (int)(lastX * (float)size), currentIdx = (int)(currentX * (float)size), deltaIdx = currentIdx - lastIdx;
                    for (int i = 0; i < deltaIdx; ++i)
                    {
                        Vector4 clr = interpolateLabColor(lastSample.Value, currentSample.Value, (float)i / (float)deltaIdx);
                        int     idx = lastIdx + i;
                        colorMap[4 * idx + 0] = (byte)clr.xyz.x;
                        colorMap[4 * idx + 1] = (byte)clr.y;
                        colorMap[4 * idx + 2] = (byte)clr.z;
                        colorMap[4 * idx + 3] = (byte)clr.w;
                    }

                    lastSample = currentSample;
                }

                return(colorMap);
            }