Example #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));
        }
Example #2
0
        internal static void DrawEntries(Rect rect, GraphEntry calls, GraphEntry times, int entries, float aliasing)
        {
            var xIncrement = rect.width / (entries - 1.0f);

            var timeCutoff  = 0.0f;
            var callsCutoff = 0.0f;

            if (aliasing != 0)
            {
                timeCutoff  = (calls.max / rect.height) / aliasing;
                callsCutoff = (times.max / rect.height) / aliasing;
            }

            int i = 1, timesIndex = 0, callsIndex = 0;

            for (; i < entries; i++)
            {
                if (calls.visible)
                {
                    if (Mathf.Abs(calls.entries[callsIndex] - calls.entries[i]) > callsCutoff || i == entries - 1) // We need to draw a line, enough of a difference
                    {
                        DrawLine(ref calls, callsIndex, i, rect.height, xIncrement, Modbase.Settings.callsColour);

                        callsIndex = i;
                    }
                }

                if (times.visible)
                {
                    if (Mathf.Abs(times.entries[timesIndex] - times.entries[i]) > timeCutoff || i == entries - 1)
                    {
                        DrawLine(ref times, timesIndex, i, rect.height, xIncrement, Modbase.Settings.timeColour);

                        timesIndex = i;
                    }
                }
            }
        }