FairyGUI.NGraphics.DrawEllipse C# (CSharp) Method

DrawEllipse() public method

public DrawEllipse ( Rect vertRect, Color fillColor, Color allColors ) : void
vertRect UnityEngine.Rect
fillColor UnityEngine.Color
allColors UnityEngine.Color
return void
        public void DrawEllipse(Rect vertRect, Color fillColor, Color[] allColors)
        {
            float radiusX = vertRect.width / 2;
            float radiusY = vertRect.height / 2;
            int numSides = Mathf.CeilToInt(Mathf.PI * (radiusX + radiusY) / 4);
            if (numSides < 6) numSides = 6;
            Alloc(numSides + 1);

            float angleDelta = 2 * Mathf.PI / numSides;
            float angle = 0;

            vertices[0] = new Vector3(radiusX, -radiusY);
            for (int i = 1; i <= numSides; i++)
            {
                vertices[i] = new Vector3(Mathf.Cos(angle) * radiusX + radiusX,
                    Mathf.Sin(angle) * radiusY - radiusY, 0);
                angle += angleDelta;
            }

            AllocTriangleArray(numSides * 3);

            int[] triangles = this.triangles;
            int k = 0;
            for (int i = 1; i < numSides; i++)
            {
                triangles[k++] = i + 1;
                triangles[k++] = i;
                triangles[k++] = 0;
            }
            triangles[k++] = 1;
            triangles[k++] = numSides;
            triangles[k++] = 0;

            if (allColors != null)
            {
                int colorCnt = allColors.Length;
                Color32[] arr = this.colors;
                arr[0] = allColors[0];
                colorCnt--;
                for (int i = 1; i <= numSides; i++)
                    arr[i] = allColors[(i - 1) % colorCnt + 1];
            }
            else
                FillColors(fillColor);

            UpdateMesh();
        }

Usage Example

 static public int DrawEllipse(IntPtr l)
 {
     try {
         FairyGUI.NGraphics self = (FairyGUI.NGraphics)checkSelf(l);
         UnityEngine.Rect   a1;
         checkValueType(l, 2, out a1);
         UnityEngine.Color a2;
         checkType(l, 3, out a2);
         self.DrawEllipse(a1, a2);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }