Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8716919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:11:46+00:00 2026-06-13T06:11:46+00:00

Basically, I want to draw a line where the mouse goes, like in paint,

  • 0

Basically, I want to draw a line where the mouse goes, like in paint, but, when I draw a dot over the mousePos every tick, this happens:

This happens

Now, I need some help turning this into a line, that doesn’t have gaps or anything weird.
Thanks for helping.

The code I’m using to generate the lines (This is not the code for in the picture!)

        protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        spriteBatch.Begin();

        Line newLine = new Line(pixel, point1, point2, 2, Color.White);
        allLines.Add(newLine);

        foreach (Line lines in allLines) 
        {
            lines.Draw(spriteBatch);
        }

        spriteBatch.End();

        base.Draw(gameTime);
    }

and the line object:

    public class Line
{
    Texture2D texture;
    Vector2 point1, point2;
    float width;
    Color color;
    float angle, length;

    public Line(Texture2D texture, Vector2 point1, Vector2 point2, float width, Color color) 
    {
        this.texture = texture;
        this.point1 = point1;
        this.point2 = point2;
        this.width = width;
        this.color = color;
        angle = (float)Math.Atan2(point2.Y - point1.Y, point2.X - point1.X);
        length = Vector2.Distance(point1, point2);
    }

    public void Draw(SpriteBatch spriteBatch) 
    {
        spriteBatch.Draw(texture, point1, null, color, angle, Vector2.Zero, new Vector2(length, width), SpriteEffects.None, 0);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:11:46+00:00Added an answer on June 13, 2026 at 6:11 am

    What your going to want to do is something like this (expanding on pathfinder666’s answer):

    private Point _lastPoint;
    
    protected void MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
    {
        Graphics g = CreateGraphics();
        g.LineTo(_lastPoint.X, _lastPoint.Y, e.X, e.Y);
        _lastPoint = new Point(e.X, e.Y);
    }
    

    Now keep in mind, this might look a little jaggedy. You may want to use DrawArc instead to smooth it out a little. It depends on what you are trying to accomplish in the end.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to draw a straight separator line on an UIView. Basically, this
I basically want something like: TextView Button Button . . . TextView TextView SeekBar
I basically want to do this in code: PersonList myPersonList; //populate myPersonList here, not
In my program I want to draw a simple score line graph. I have
What I want to do is to draw a line that will follow my
What I have: To create this line, I basically have an UIView and I
I basically want to show a UITableViewCellAccessoryDisclosureIndicator depending on certain situations, in this case,
I'm making a simple prototype in HTML5 canvas, and want to basically draw a
This is mostly a theoretical question. Let's say I want to draw a triangle
I basically want to setup a relationship similar to Netflix's DVD rental model. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.