Search Unity

[VectorLine] How can I control the closeness of two consequtive points when drawing a line

Discussion in '2D' started by adityaponnada, May 21, 2018.

  1. adityaponnada

    adityaponnada

    Joined:
    Jan 9, 2018
    Posts:
    1
    In my project, I am using VectorLine class to draw graphs on the screen. The data is very dense (sampling rate 20Hz). Therefore, I want to be able to control how far apart the two points can be on the x-axis. So far I am not sure if VectorLine allows that to happen. Here is a snapshot of how close these points are (I would want them to be a lot closer):

    Here is a snapshot of how I am drawing this:

    Code (CSharp):
    1. public VectorLine (string name, List<Vector2> points, Texture texture, float width, LineType lineType, Joins joins);
    2.  
    3. public void setLine()
    4.     {
    5.         int i = 0;
    6.         foreach (SignalGraphData block in blocks)
    7.         {
    8.             y1.Add(new VectorLine("signalX" + i, block.y1, thickness, LineType.Continuous, Joins.Weld));
    9.             y1[i].endCap = "Arrow";
    10.             y1[i].color = xColor;
    11.             y1[i].drawTransform = this.transform;
    12.             y1[i].rectTransform.localPosition = new Vector3(y1[i].rectTransform.localPosition.x, y1[i].rectTransform.localPosition.y - 7f, 0);
    13.             //Debug.Log (y1 [i].rectTransform.localPosition.x + "  " + y1 [i].rectTransform.localPosition.y);
    14.             y2.Add(new VectorLine("signalY" + i, block.y2, thickness, LineType.Continuous, Joins.Weld));
    15.             y2[i].endCap = "Arrow";
    16.             y2[i].color = yColor;
    17.             y2[i].drawTransform = this.transform;
    18.             y2[i].rectTransform.localPosition = new Vector3(y2[i].rectTransform.localPosition.x, y2[i].rectTransform.localPosition.y - 7f, 0);
    19.  
    20.             y3.Add(new VectorLine("signalZ" + i, block.y3, thickness, LineType.Continuous, Joins.Weld));
    21.             y3[i].endCap = "Arrow";
    22.             y3[i].color = zColor;
    23.             y3[i].drawTransform = this.transform;
    24.             y3[i].rectTransform.localPosition = new Vector3(y3[i].rectTransform.localPosition.x, y3[i].rectTransform.localPosition.y - 7f, 0);
    25.             i++;
    26.         }
    27.  
    28.         //Debug.Log ("POSITION: " + blocks [blocks.Count - 1].y3 [y3.Count - 1].rectTransform.localPosition.x);
    29.  
    30.  
    31.  
    32.     }
     

    Attached Files: