예제 #1
0
 public void Show(TEllipse ellipse, Color color)
 {
     m_type    = EGraphType.Ellipse;
     m_ellipse = ellipse;
     m_color   = color;
     isShow    = true;
 }
예제 #2
0
        public bool IsOverLapWith(TEllipse ellipse)
        {
            Vector2 s1 = this.size;
            Vector2 s2 = ellipse.size;
            Vector2 p1 = this.center;
            Vector2 p2 = ellipse.center;

            s1.x = Mathf.Max(0.001f, s1.x);
            s1.y = Mathf.Max(0.001f, s1.y);
            s2.x = Mathf.Max(0.001f, s2.x);
            s2.y = Mathf.Max(0.001f, s2.y);

            s1 *= 0.5f;
            s2 *= 0.5f;

            float ratio = s2.x / s2.y;

            s2.y  = s2.x;
            p2.y *= ratio;
            s1.y *= ratio;
            p1.y *= ratio;

            s1.x += s2.x;
            s1.y += s2.x;

            float   a         = 0;
            float   b         = 0;
            float   c         = 0;
            float   standDist = 0;
            Vector2 c0        = Vector2.zero;
            Vector2 c1        = Vector2.zero;

            if (s1.x > s1.y)
            {
                a         = s1.x;
                b         = s1.y;
                c         = Mathf.Sqrt(a * a - b * b);
                standDist = 2 * a;
                c0        = new Vector2(p1.x - c, p1.y);
                c1        = new Vector2(p1.x + c, p1.y);
            }
            else
            {
                a         = s1.y;
                b         = s1.x;
                c         = Mathf.Sqrt(a * a - b * b);
                standDist = 2 * a;
                c0        = new Vector2(p1.x, p1.y - c);
                c1        = new Vector2(p1.x, p1.y + c);
            }

            float p2ToCCDist = Vector2.Distance(p2, c0) + Vector2.Distance(p2, c1);

            if (p2ToCCDist < standDist)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
        public static void DrawEllipse(TEllipse ellipse, Color color, string drawOncePerFrameKey = null)
        {
            if (ins == null || !CheckDrawCount(drawOncePerFrameKey))
            {
                return;
            }
            var item = ins.CreateGraph();

            if (item != null)
            {
                item.Show(ellipse, color);
            }
        }
예제 #4
0
 public void DrawScreenEllipse(TEllipse ellipse, Color color, int smooth = 50)
 {
     DrawScreenEllipse(ellipse.center, ellipse.xRadius, ellipse.yRadius, color, smooth);
 }
예제 #5
0
 public static TEllipse Lerp(TEllipse a, TEllipse b, float t)
 {
     return(new TEllipse(Vector2.Lerp(a.center, b.center, t), Vector2.Lerp(a.size, b.size, t)));
 }