Example #1
0
 public void DisplayGraphic()
 {
     try
     {
         ExpressionTree tree = new ExpressionTree(txt_input.Text);
         if (pbox_function.Image != null)
         {
             pbox_function.Image.Dispose();
         }
         pbox_function.Image = GraphDrawer.Draw(tree, zoom, cameraX, cameraY, pbox_function.Width / 4, pbox_function.Height / 4);
     }
     catch { }
 }
    private static void OnGUI()
    {
        if (!s_displayGraph)
        {
            return;
        }

        int curveI = 0;

        GraphDrawer.Curve GetCurve()
        {
            if (curveI == s_curveCache.Count)
            {
                s_curveCache.Add(new GraphDrawer.Curve());
            }
            return(s_curveCache[curveI]);
        }

        for (int i = 0; i < s_loggedCurves.Count; i++)
        {
            LoggedCurve loggedCurve = s_loggedCurves[i];

            // remove all points that are older than TIME_RANGE
            for (int p = 0; p < loggedCurve.Points.Count - 1; p++)
            {
                if (Time.time - loggedCurve.Points[p].x > TIME_RANGE &&
                    Time.time - loggedCurve.Points[p + 1].x > TIME_RANGE)
                {
                    loggedCurve.Points.RemoveAt(p);
                    p--;
                }
            }

            if (loggedCurve.Points.Count == 0)
            {
                s_loggedCurves.RemoveAt(i);
                i--;
            }
            else
            {
                GraphDrawer.Curve coloredCurve = GetCurve();

                coloredCurve.Positions.Clear();
                coloredCurve.Positions.AddRange(loggedCurve.Points);
            }
        }

        s_graphDrawer.ScreenDisplayRect.xMin = Time.time - TIME_RANGE;
        s_graphDrawer.ScreenDisplayRect.xMax = Time.time;
        s_graphDrawer.Draw();
    }
        void OnDrawGpuGraph(CanvasControl sender, CanvasDrawEventArgs args)
        {
            var graphDrawer = new GraphDrawer((float)sender.ActualWidth, (float)sender.ActualHeight, Scenarios, e => e.GpuTimeInMs, "GPU");

            graphDrawer.Draw(args.DrawingSession);
        }
Example #4
0
 void OnDrawGpuGraph(CanvasControl sender, CanvasDrawEventArgs args)
 {
     var graphDrawer = new GraphDrawer((float)sender.ActualWidth, (float)sender.ActualHeight, Scenarios, e => e.GpuTimeInMs, "GPU");
     graphDrawer.Draw(args.DrawingSession);
 }