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 7923741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:24:56+00:00 2026-06-03T17:24:56+00:00

I Have a bresenham algorithm which I wrote it in class Line I Can

  • 0

I Have a bresenham algorithm which I wrote it in class Line
I Can draw lines Now I wanted to draw polygons so I wrote it’s function(void Polygon)
I should store coordinates of each click in an array and then my function should get them
I don’t know how to store each click
Radiobutton1 is for draw line and radiobutton2 is for drawing polygons

private void panel1_MouseClick(object sender, MouseEventArgs e)
        {           
           if(radioButton1.Checked)
            if (firstClick)
            {
                firstX = e.X;
                firstY = e.Y;
                firstClick = false;
            }
            else
            {
              Line l = new Line(firstX, firstY, e.X, e.Y, panel1.CreateGraphics(), Convert.ToInt32(textBox1.Text));

              firstClick = true;

            }
           if(radioButton2.Checked)
            {
       //how to write here so as to store each click in array

                }
            }

        private void button1_Click(object sender, EventArgs e)
        {
            int n = Convert.ToInt32(textBox2.Text);

            Polygon(n, coor);
        }
   void Polygon(int n,int[] coordinates)
     {
       if(n>=2)
      {
         Line l=new Line(coordinates[0],coordinates[1],coordinates[2],coordinates[3],panel1.CreateGraphics(), Convert.ToInt32(textBox1.Text));
         for(int count=1;count<(n-1);count++)
             l=new Line(coordinates[(count*2)],coordinates[((count*2)+1)],coordinates[((count+1)*2)],coordinates[(((count+1)*2)+1)],panel1.CreateGraphics(), Convert.ToInt32(textBox1.Text));
      }
  • 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-03T17:24:58+00:00Added an answer on June 3, 2026 at 5:24 pm

    You can make a point of the click coordinates:

    Point p = new Point(e.x, e.y);
    

    Save the points you get in a List:

    // Declaration:
    List<Point> myPoints = new List<Point>();
    
    // in the method: 
    if (radioButton2.Checked) {
       myPoints.Add(new Point(e.x, e.y));
    }
    

    An array will not be a good idea, because you normally don’t have any idea how many clicks there will be. A List is of variable length, so it’s useful in this situation.

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

Sidebar

Related Questions

I have images which have line segments, rays etc. I am representing these line
I am using OpenGL/GLUT to implement Bresenham's line drawing algorithm and having some issues
I need the fastest sphere mapping algorithm. Something like Bresenham's line drawing one. Something
For my graphics course we were taught the Naive line rasterizing algorithm then Bresenham's
I have to find all tiles that intersected by line segment but Bresenham's line
Have a matrix report now that has Position, Hours and Wages for a location
**Have it working now. I forgot to populate the Array List. How embarrassing. I'm
have anyone can tell me what syntax error on this actionscript (actionscript3.0)? var rotY:
have been trying couple of hours now to make my iphone app universal. The
Have just started using Visual Studio Professional's built-in unit testing features, which as I

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.