FairyGUI.FillUtils.FillRadial90 C# (CSharp) Method

FillRadial90() public static method

public static FillRadial90 ( Origin90 origin, float amount, bool clockwise, Rect vertRect, Rect uvRect, Vector3 verts, Vector2 uv ) : void
origin Origin90
amount float
clockwise bool
vertRect UnityEngine.Rect
uvRect UnityEngine.Rect
verts UnityEngine.Vector3
uv UnityEngine.Vector2
return void
        public static void FillRadial90(Origin90 origin, float amount, bool clockwise, Rect vertRect, Rect uvRect, Vector3[] verts, Vector2[] uv)
        {
            NGraphics.FillVertsOfQuad(verts, 0, vertRect);
            NGraphics.FillUVOfQuad(uv, 0, uvRect);
            if (amount < 0.001f)
            {
                verts[0] = verts[1] = verts[2] = verts[3];
                uv[0] = uv[1] = uv[2] = uv[3];
                return;
            }
            if (amount > 0.999f)
                return;

            switch (origin)
            {
                case Origin90.BottomLeft:
                    {
                        if (clockwise)
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * (1 - amount));
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[2].x -= vertRect.width * ratio;
                                verts[3] = verts[2];

                                uv[2].x -= uvRect.width * ratio;
                                uv[3] = uv[2];
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[3].y += h;
                                uv[3].y += uvRect.height * ratio;
                            }
                        }
                        else
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * amount);
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[1].x += vertRect.width * (1 - ratio);
                                uv[1].x += uvRect.width * (1 - ratio);
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[2].y -= vertRect.height * (1 - ratio);
                                verts[1] = verts[2];

                                uv[2].y -= uvRect.height * (1 - ratio);
                                uv[1] = uv[2];
                            }
                        }
                    }
                    break;

                case Origin90.BottomRight:
                    {
                        if (clockwise)
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * amount);
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[2].x -= vertRect.width * (1 - ratio);
                                uv[2].x -= uvRect.width * (1 - ratio);
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[1].y -= vertRect.height * (1 - ratio);
                                verts[2] = verts[3];

                                uv[1].y -= uvRect.height * (1 - ratio);
                                uv[2] = uv[3];
                            }
                        }
                        else
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * (1 - amount));
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[1].x += vertRect.width * ratio;
                                verts[0] = verts[1];

                                uv[1].x += uvRect.width * ratio;
                                uv[0] = uv[1];
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[0].y += h;
                                uv[0].y += uvRect.height * ratio;
                            }
                        }
                    }
                    break;

                case Origin90.TopLeft:
                    {
                        if (clockwise)
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * amount);
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[0].x += vertRect.width * (1 - ratio);
                                uv[0].x += uvRect.width * (1 - ratio);
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[3].y += vertRect.height * (1 - ratio);
                                verts[0] = verts[3];

                                uv[3].y += uvRect.height * (1 - ratio);
                                uv[0] = uv[3];
                            }
                        }
                        else
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * (1 - amount));
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[3].x -= vertRect.width * ratio;
                                verts[2] = verts[3];
                                uv[3].x -= uvRect.width * ratio;
                                uv[2] = uv[3];
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[2].y -= h;
                                uv[2].y -= uvRect.height * ratio;
                            }
                        }
                    }
                    break;

                case Origin90.TopRight:
                    {
                        if (clockwise)
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * (1 - amount));
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[0].x += vertRect.width * ratio;
                                verts[1] = verts[2];
                                uv[0].x += uvRect.width * ratio;
                                uv[1] = uv[2];
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[1].y -= vertRect.height * ratio;
                                uv[1].y -= uvRect.height * ratio;
                            }
                        }
                        else
                        {
                            float v = Mathf.Tan(Mathf.PI / 2 * amount);
                            float h = vertRect.width * v;
                            if (h > vertRect.height)
                            {
                                float ratio = (h - vertRect.height) / h;
                                verts[3].x -= vertRect.width * (1 - ratio);
                                uv[3].x -= uvRect.width * (1 - ratio);
                            }
                            else
                            {
                                float ratio = h / vertRect.height;
                                verts[0].y += vertRect.height * (1 - ratio);
                                verts[3] = verts[0];
                                uv[0].y += uvRect.height * (1 - ratio);
                                uv[3] = uv[0];
                            }
                        }
                    }
                    break;
            }
        }

Usage Example

Example #1
0
        public void Fill(FillMethod method, float amount, int origin, bool clockwise, Rect vertRect, Rect uvRect)
        {
            amount = Mathf.Clamp01(amount);
            switch (method)
            {
            case FillMethod.Horizontal:
                Alloc(4);
                FillUtils.FillHorizontal((OriginHorizontal)origin, amount, vertRect, uvRect, vertices, uv);
                break;

            case FillMethod.Vertical:
                Alloc(4);
                FillUtils.FillVertical((OriginVertical)origin, amount, vertRect, uvRect, vertices, uv);
                break;

            case FillMethod.Radial90:
                Alloc(4);
                FillUtils.FillRadial90((Origin90)origin, amount, clockwise, vertRect, uvRect, vertices, uv);
                break;

            case FillMethod.Radial180:
                Alloc(8);
                FillUtils.FillRadial180((Origin180)origin, amount, clockwise, vertRect, uvRect, vertices, uv);
                break;

            case FillMethod.Radial360:
                Alloc(12);
                FillUtils.FillRadial360((Origin360)origin, amount, clockwise, vertRect, uvRect, vertices, uv);
                break;
            }
        }
All Usage Examples Of FairyGUI.FillUtils::FillRadial90