예제 #1
0
        public static void DrawLine(Vector2 point1, Vector2 point2, Color c, SpriteBatch b, byte alpha = 255)
        {
            Vector2   midpoint = ConversionManager.MidPoint(point1, point2);
            float     xd       = midpoint.X - point2.X;
            float     yd       = midpoint.Y - point2.Y;
            double    rotation = Math.Atan2(yd, xd);
            float     dist     = Vector2.Distance(midpoint, point2) * 2;
            Texture2D t        = GeeUIMain.White;

            c.A = alpha;
            b.Draw(t, point2, null, c, (float)rotation, Vector2.Zero, new Vector2(dist, 1), SpriteEffects.None, 0);
        }
예제 #2
0
        public static void DrawBezier(Vector2 point1, Vector2 point2, Color c, SpriteBatch b, byte alpha = 255)
        {
            Vector2 midpoint = ConversionManager.MidPoint(point1, point2);


            var c1 = new Vector2(midpoint.X, point1.Y);
            var c2 = new Vector2(midpoint.X, point2.Y);

            Vector2 lastPoint = point1;

            for (double t1 = 0; t1 <= 1; t1 += (double)1 / (double)30)
            {
                var t = (float)t1;

                Vector2 point = ((1 - t) * (1 - t) * (1 - t)) * point1 + 3 * ((1 - t) * (1 - t)) * t * c1 + 3 * (1 - t) * (t * t) * c2 + (t * t * t) * point2;

                DrawLine(point, lastPoint, c, b, alpha);

                lastPoint = point;
            }
        }