Exemple #1
0
        internal static Vector2 DrawLine(GraphEntry value, int prevIndex, int nextIndex, float rectHeight, float xIncrement, Color color)
        {
            float GetAdjustedY(float y, float max)
            {
                return(rectHeight - rectHeight * .95f * (y / max));
            }

            var prevY = GetAdjustedY(value.entries[prevIndex], value.max);
            var nextY = GetAdjustedY(value.entries[nextIndex], value.max);

            if (prevIndex != nextIndex - 1) // We have aliased a point (or multiple) we need to draw two lines.
            {
                var prevDrawnPoint = new Vector2(prevIndex * xIncrement, prevY);
                var prevPoint      = new Vector2((nextIndex - 1) * xIncrement, prevY);
                var curPoint       = new Vector2(nextIndex * xIncrement, nextY);
                DubGUI.DrawLine(prevDrawnPoint, prevPoint, color, 1f, true);
                DubGUI.DrawLine(prevPoint, curPoint, color, 1f, true);
            }
            else
            {
                DubGUI.DrawLine(new Vector2(prevIndex * xIncrement, prevY), new Vector2(nextIndex * xIncrement, nextY), color, 1f, true);
            }

            return(new Vector2(prevIndex * xIncrement, prevY));
        }