Beispiel #1
0
        // simple drawing of 1 pixel line using bresnenhams
        public static void DrawLine(this SpriteBatch @this, Vector2 start, int length, float angleInDegrees, Color Colour)
        {
            var texture = SpriteBatchExtensions.GetOnePixelTexture(@this.GraphicsDevice);

            var endVector = GeneralExtensions.UnitAngleVector(angleInDegrees, length);
            // negation of x was ngation of y not sure why it works.
            var endPoint = start + endVector;
            // create the list of points
            var lineData = Bresenham.GetLine(start.ToPoint(), endPoint.ToPoint());

            lineData.ToList().ForEach(a => @this.Draw(texture, a.ToVector2(), Color.White));
        }
Beispiel #2
0
        public static void DrawFilledRect(this SpriteBatch @this, Vector2 start, int width, int height, Color Colour)
        {
            var texture = SpriteBatchExtensions.GetOnePixelTexture(@this.GraphicsDevice);

            @this.Draw(texture, new Rectangle(start.ToPoint(), new Point(width, height)), Colour);
        }