Ejemplo n.º 1
0
        private void DrawnPath(Rect r, recordType type, double scaleX, bool downRange, Color color)
        {
            if (recorder.history.Length <= 2 || recorder.historyIdx == 0)
            {
                return;
            }

            graphState graphState = graphStates[(int)type];

            double scaleY = (graphState.maximum - graphState.minimum) / height;

            float yBase = r.yMax + (float)(graphState.minimum / scaleY);

            Vector2 p1 = new Vector2(r.xMin + (float)((downRange ? recorder.history[0].downRange : recorder.history[0].timeSinceMark) / scaleX), yBase - (float)(recorder.history[0][type] / scaleY));
            Vector2 p2 = new Vector2();

            int t = 1;

            while (t <= recorder.historyIdx && t < recorder.history.Length)
            {
                var rec = recorder.history[t];
                p2.x = r.xMin + (float)((downRange ? rec.downRange : rec.timeSinceMark) / scaleX);
                p2.y = yBase - (float)(rec[type] / scaleY);

                // skip 0 length line but always drawn the first 2 points
                if (r.Contains(p2) && ((p1 - p2).sqrMagnitude >= 1.0 || t < 2))
                {
                    Drawing.DrawLine(p1, p2, color, 2, true);

                    p1.x = p2.x;
                    p1.y = p2.y;
                }
                t++;
            }
        }
        private void DrawnPath(Rect r, recordType type, float minimum, double scaleX, bool downRange, Color color)
        {
            if (recorder.history.Length <= 2 || recorder.historyIdx == 0)
                return;

            graphState graphState = graphStates[(int)type];

            double scaleY = (graphState.maximum - graphState.minimum) / height;

            double invScaleX = 1 / scaleX;
            double invScaleY = 1 / scaleY;

            float xBase = (float) (r.xMin - (minimum * invScaleX));
            float yBase = r.yMax + (float)(graphState.minimum * invScaleY);

            Vector2 p1 = new Vector2(xBase + (float)((downRange ? recorder.history[0].downRange : recorder.history[0].timeSinceMark) * invScaleX), yBase - (float)(recorder.history[0][type] * invScaleY));
            Vector2 p2 = new Vector2();

            int t = 1;
            while (t <= recorder.historyIdx && t < recorder.history.Length)
            {
                var rec = recorder.history[t];
                p2.x = xBase + (float)((downRange ? rec.downRange : rec.timeSinceMark) * invScaleX);
                p2.y = yBase - (float)(rec[type] * invScaleY);

                // skip 0 length line but always drawn the first 2 points
                if (r.Contains(p2) && ((p1 - p2).sqrMagnitude >= 1.0 || t < 2))
                {
                    Drawing.DrawLine(p1, p2, color, 2, true);

                    p1.x = p2.x;
                    p1.y = p2.y;
                }
                t++;
            }
        }