Beispiel #1
0
        /// <summary>
        /// 画数据折线
        /// </summary>
        private void DrawLine(VertexHelper vh)
        {
            foreach (var data in datas)
            {
                Vector2[] pixelPoints = new Vector2[data.Length];
                for (int i = 0; i < data.Length; i++)
                {
                    pixelPoints[i].x = (data[i].x - axleMinValue.x) / axleMaxValue.x * width;
                    pixelPoints[i].y = (data[i].y - axleMinValue.y) / axleMaxValue.y * height;
                    pixelPoints[i]  += offset;
                }

                UIVertex[] verts = new UIVertex[4];
                for (int i = 0; i < verts.Length; i++)
                {
                    verts[i].color = lineColor;
                }

                for (int i = 0; i < pixelPoints.Length - 1; i++)
                {
                    SetVerts(pixelPoints[i], pixelPoints[i + 1], lineWidth, verts);
                    vh.AddUIVertexQuad(verts);
                }

                // 点状数据
                //foreach (var item in pixelPoints)
                //{
                //    verts[0].position = item;
                //    verts[1].position = new Vector2(5, 0) + item;
                //    verts[2].position = new Vector2(5, 5) + item;
                //    verts[3].position = new Vector2(0, 5) + item;
                //    vh.AddUIVertexQuad(verts);
                //}

                void SetVerts(Vector2 _start, Vector2 _end, float _width, UIVertex[] _verts)
                {
                    Vector2[] tmp = Math2d.GetRect(_start, _end, _width);
                    _verts[0].position = tmp[0];
                    _verts[1].position = tmp[1];
                    _verts[2].position = tmp[3];
                    _verts[3].position = tmp[2];
                }
            }
        }