private List <Vector2> MakeRoundRectLineLoop(BoundRect br, float cornerR, float arcMax)
        {
            int cornerDiv = Mathf.Max(4, (int)Mathf.Ceil(cornerR * Mathf.PI * 0.5f / arcMax));
            // Debug.Log("div:" + cornerDiv);

            float angle_offset;
            var   innerCorners = new Vector2[4];

            if (br.GetAspectRatio() < 1.0f)
            {
                angle_offset    = 0.0f;
                innerCorners[0] = new Vector2(br.right - cornerR, br.top - cornerR);
                innerCorners[1] = new Vector2(br.right - cornerR, br.bottom + cornerR);
                innerCorners[2] = new Vector2(br.left + cornerR, br.bottom + cornerR);
                innerCorners[3] = new Vector2(br.left + cornerR, br.top - cornerR);
            }
            else
            {
                angle_offset    = Mathf.PI * 0.5f;
                innerCorners[0] = new Vector2(br.right - cornerR, br.bottom + cornerR);
                innerCorners[1] = new Vector2(br.left + cornerR, br.bottom + cornerR);
                innerCorners[2] = new Vector2(br.left + cornerR, br.top - cornerR);
                innerCorners[3] = new Vector2(br.right - cornerR, br.top - cornerR);
            }

            var ret = new List <Vector2>(cornerDiv * 4 + 4);

            for (int i = 0; i < 4; i++)
            {
                Vector2 ip         = innerCorners[i];
                float   base_angle = Mathf.PI * 2.0f * (float)i * 0.25f + angle_offset;

                for (int div = 0; div <= cornerDiv; div++)
                {
                    float angle = (float)div / (float)cornerDiv * Mathf.PI * 0.5f + base_angle;

                    var v = new Vector2(
                        Mathf.Sin(angle) * cornerR + ip.x,
                        Mathf.Cos(angle) * cornerR + ip.y
                        );
                    ret.Add(v);
                }
            }

            // To make beaty fill mesh.
            int lastindex = ret.Count - 1;
            var tmpv      = ret[lastindex];

            ret.RemoveAt(lastindex);
            ret.Insert(0, tmpv);

            return(ret);
        }
        private List <Vector2> MakeCapsuleLineLoop(BoundRect br, float arcMax)
        {
            float capRadius = Mathf.Min(br.GetWidth(), br.GetHeight()) * 0.5f;
            int   capDiv    = Mathf.Max(4, (int)Mathf.Ceil(capRadius * Mathf.PI / arcMax)) & (~0x1);
            // Debug.Log("div:" + cornerDiv);

            float angle_offset;
            var   capPivots = new Vector2[4];

            if (br.GetAspectRatio() < 1.0f)
            {
                angle_offset = Mathf.PI * -0.5f;
                capPivots[0] = new Vector2((br.left + br.right) * 0.5f, br.top - capRadius);
                capPivots[1] = new Vector2((br.left + br.right) * 0.5f, br.bottom + capRadius);
            }
            else
            {
                angle_offset = 0.0f;
                capPivots[0] = new Vector2(br.right - capRadius, (br.top + br.bottom) * 0.5f);
                capPivots[1] = new Vector2(br.left + capRadius, (br.top + br.bottom) * 0.5f);
            }

            var ret = new List <Vector2>(capDiv * 2 + 2);

            for (int i = 0; i < 2; i++)
            {
                Vector2 cp         = capPivots[i];
                float   base_angle = Mathf.PI * 2.0f * (float)i * 0.5f + angle_offset;

                for (int div = 0; div <= capDiv; div++)
                {
                    float angle = (float)div / (float)capDiv * Mathf.PI + base_angle;

                    var v = new Vector2(
                        Mathf.Sin(angle) * capRadius + cp.x,
                        Mathf.Cos(angle) * capRadius + cp.y
                        );
                    ret.Add(v);
                }
            }

            // To make beaty fill mesh.
            for (int i = 0; i < capDiv / 2; i++)
            {
                var tmpv = ret[0];
                ret.RemoveAt(0);
                ret.Add(tmpv);
            }

            return(ret);
        }