Esempio n. 1
0
        private List <UIVertex> DrawThumbnail()
        {
            List <UIVertex> vertexs  = new List <UIVertex>();
            Vector2         origin   = new Vector2(PieRadius, -PieRadius) * 1.2f + new Vector2(0, PieRadius * 0.2f);
            float           lenght   = 12;
            float           height   = 6;
            float           interval = 3;

            for (int i = 0; i < PieData.PieDatas.Count; i++)
            {
                DWEPieData data   = PieData.PieDatas[i];
                Vector2    first  = new Vector2(origin.x, origin.y + interval * i + height * (i + 1));
                Vector2    second = new Vector2(origin.x, origin.y + height + interval * i + height * (i + 1));
                Vector2    third  = new Vector2(origin.x + lenght, origin.y + interval * i + height * (i + 1));
                Vector2    four   = new Vector2(origin.x + lenght, origin.y + height + interval * i + height * (i + 1));
                vertexs.Add(GetUIVertex(first, data.Color));
                vertexs.Add(GetUIVertex(second, data.Color));
                vertexs.Add(GetUIVertex(third, data.Color));
                vertexs.Add(GetUIVertex(third, data.Color));
                vertexs.Add(GetUIVertex(second, data.Color));
                vertexs.Add(GetUIVertex(four, data.Color));
            }
            return(vertexs);
        }
Esempio n. 2
0
        private List <UIVertex> DrawPie()
        {
            if (IsShowPercnet)
            {
                _pieText = new List <DWEPieText>();
            }
            List <UIVertex> vertexs = new List <UIVertex>();

            float perRadian     = Mathf.PI * 2 / Smooth;
            float totalRadian   = 0;
            float boomRadian    = BoomDegree / 180 * Mathf.PI;
            float pieRadianBase = Mathf.PI * 2 - boomRadian * PieData.PieDatas.Count;

            for (int i = 0; i < PieData.PieDatas.Count; i++)
            {
                DWEPieData data      = PieData.PieDatas[i];
                float      endRadian = boomRadian + data.Percent * pieRadianBase + totalRadian;
                for (float r = boomRadian + totalRadian; r < endRadian; r += perRadian)
                {
                    Vector2 first  = new Vector2(Mathf.Cos(r), Mathf.Sin(r)) * HollowWidth;
                    Vector2 second = new Vector2(Mathf.Cos(r + perRadian), Mathf.Sin(r + perRadian)) * HollowWidth;
                    Vector2 third  = new Vector2(Mathf.Cos(r), Mathf.Sin(r)) * PieRadius;
                    Vector2 four   = new Vector2(Mathf.Cos(r + perRadian), Mathf.Sin(r + perRadian)) * PieRadius;
                    vertexs.Add(GetUIVertex(first, data.Color));
                    vertexs.Add(GetUIVertex(third, data.Color));
                    vertexs.Add(GetUIVertex(second, data.Color));
                    vertexs.Add(GetUIVertex(second, data.Color));
                    vertexs.Add(GetUIVertex(third, data.Color));
                    vertexs.Add(GetUIVertex(four, data.Color));
                }

                if (IsShowPercnet)
                {
                    float   middleRadian     = boomRadian + data.Percent * pieRadianBase / 2 + totalRadian;
                    float   brokenLineLength = PieRadius * 0.2f;
                    Vector2 middlePoint      = new Vector2(Mathf.Cos(middleRadian), Mathf.Sin(middleRadian)) * PieRadius;
                    Vector2 secondPoint      = middlePoint + new Vector2(Mathf.Cos(middleRadian), Mathf.Sin(middleRadian)) * brokenLineLength;

                    Vector2 first  = middlePoint + new Vector2(Mathf.Sin(middleRadian), -Mathf.Cos(middleRadian)) * BrokenLineWidth / 2;
                    Vector2 second = middlePoint + new Vector2(-Mathf.Sin(middleRadian), Mathf.Cos(middleRadian)) * BrokenLineWidth / 2;
                    Vector2 third  = secondPoint + new Vector2(Mathf.Sin(middleRadian), -Mathf.Cos(middleRadian)) * BrokenLineWidth / 2;
                    Vector2 four   = secondPoint + new Vector2(-Mathf.Sin(middleRadian), Mathf.Cos(middleRadian)) * BrokenLineWidth / 2;

                    Vector2 five;
                    Vector2 six;
                    Vector2 seven;
                    Vector2 eight;

                    vertexs.Add(GetUIVertex(first, data.Color));
                    vertexs.Add(GetUIVertex(second, data.Color));
                    vertexs.Add(GetUIVertex(third, data.Color));

                    vertexs.Add(GetUIVertex(third, data.Color));
                    vertexs.Add(GetUIVertex(second, data.Color));
                    vertexs.Add(GetUIVertex(four, data.Color));

                    five = secondPoint + new Vector2(0, BrokenLineWidth / 2.0f);
                    six  = secondPoint + new Vector2(0, -BrokenLineWidth / 2.0f);

                    if (middleRadian > Mathf.PI / 2 && middleRadian < Mathf.PI * 3 / 2)
                    {
                        seven = five + new Vector2(-brokenLineLength, 0);
                        eight = six + new Vector2(-brokenLineLength, 0);
                        //绘制右边的文字
                        _pieText.Add(new DWEPieText(data.Percent * 100 + "%" + labelName[i], eight, false));
                    }
                    else
                    {
                        seven = five + new Vector2(brokenLineLength, 0);
                        eight = six + new Vector2(brokenLineLength, 0);
                        //绘制左边的文字
                        _pieText.Add(new DWEPieText(data.Percent * 100 + "%" + labelName[i], eight, true));
                    }

                    vertexs.Add(GetUIVertex(third, data.Color));
                    vertexs.Add(GetUIVertex(four, data.Color));
                    vertexs.Add(GetUIVertex(five, data.Color));

                    vertexs.Add(GetUIVertex(five, data.Color));
                    vertexs.Add(GetUIVertex(six, data.Color));
                    vertexs.Add(GetUIVertex(third, data.Color));

                    vertexs.Add(GetUIVertex(five, data.Color));
                    vertexs.Add(GetUIVertex(six, data.Color));
                    vertexs.Add(GetUIVertex(seven, data.Color));

                    vertexs.Add(GetUIVertex(seven, data.Color));
                    vertexs.Add(GetUIVertex(eight, data.Color));
                    vertexs.Add(GetUIVertex(six, data.Color));
                }
                totalRadian = endRadian;
            }

            if (IsShowThumbnail)
            {
                vertexs.AddRange(DrawThumbnail());
            }
            return(vertexs);
        }