GridViewer.CatesianGrid.GetTextureCoords C# (CSharp) Method

GetTextureCoords() private method

private GetTextureCoords ( GridBlockProperty property ) : float[]
property GridBlockProperty
return float[]
        private float[] GetTextureCoords(GridBlockProperty property)
        {
            int[] gridIndexes = property.Positions;
            float[] values = property.Values;
            int[] resultsVisibles = this.DataSource.ExpandVisibles(gridIndexes);
            int[] bindVisibles = this.DataSource.BindCellActive(this.DataSource.BindVisibles, resultsVisibles);

            int dimenSize = this.DataSource.DimenSize;
            float[] textures = this.DataSource.GetInvisibleTextureCoords();
            float distance = Math.Abs(this.MaxColorCode - this.MinColorCode);
            for (int i = 0; i < gridIndexes.Length; i++)
            {
                int gridIndex = gridIndexes[i];
                float value = values[i];
                if (value < this.MinColorCode)
                {
                    value = this.MinColorCode;
                    bindVisibles[gridIndex] = 0;
                }
                if (value > this.MaxColorCode)
                {
                    value = this.MaxColorCode;
                    bindVisibles[gridIndex] = 0;
                }

                if (bindVisibles[gridIndex] > 0)
                {
                    if (!(distance <= 0.0f))
                    {
                        textures[gridIndex] = (value - this.MinColorCode) / distance;
                        if (textures[gridIndex] < 0.5f)
                        {
                            textures[gridIndex] = 0.5f - (0.5f - textures[gridIndex]) * 0.99f;
                        }
                        else
                        {
                            textures[gridIndex] = (textures[gridIndex] - 0.5f) * 0.99f + 0.5f;
                        }
                    }
                    else
                    {
                        //最小值最大值相等时,显示最小值的颜色
                        //textures[gridIndex] = 0.01f;
                        textures[gridIndex] = 0.01f;
                    }
                }
            }

            return textures;
        }