draw line with exist coordinates

genia1991

New member
Joined
Jul 11, 2021
Messages
2
Programming Experience
Beginner
Hi everyone. I am beginner in c# language. and I want ask you to help me. I really is in dead end:rolleyes:

I have X Y coordinates and I wanna to draw a line (like in that video on youtube. link below) with these exist information. Is there the simpliest way how to do that?
Just to make the same result like in that video.


Thanks in advance to everyone with any help
 
If you look at the Graphics object documentation, you'll find some methods for drawing lines between points.

Having written as wobble simulator like that before for my personal shooting training, one of the more interesting things to find is not the trace of the aiming point, but the trace over time. There is a magic few seconds after the natural point of aim has been established, and the area of the wobble as well as the pattern settles to a nice predictable path, and then later fatigue starts to kick in and the shooter should recognize it is time to let go of the hold and start over.
 
Last edited:
I have first success :)
but still have some bugs with this (
here is example pic (attached)

code:
                        float x1;  
                        float y1;
                        float x2;
                        float y2;
                     
                        Graphics gg = pictureBox3.CreateGraphics();
                        // Create pen.
                        Pen blackPen = new Pen(Color.Green, 3);
                        // Create coordinates of points that define line.
                         x2 = center.X;
                         y2 = center.Y;
                        // Draw line to screen.
                        //gg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        //gg.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                        gg.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // DOES NOT WORK                      
                        gg.DrawLine(blackPen, x1, y1, x2, y2);
                         x1 = x2;
                         y1 = y2;
 

Attachments

  • gwrgrwg.JPG
    gwrgrwg.JPG
    23 KB · Views: 15
  • 6666.JPG
    6666.JPG
    16.3 KB · Views: 16
Last edited:
I doubt those are bugs. Windows GDI has been around for a long time. I suspect that is really what your data is representing.

Also, try a pen width of just 1, instead of 3.

Also there is this method:
 
You can only expect so much from winforms.

WPF is a lot better and much more efficient for drawing. However, I think regardless what you use to draw in windows, you will always notice some type of botching, rigidness, pixilation, but Skydiver is right, that thick pen isn't helping you. One thing that might help you but may require a lot more code is to add semi-transparent transitioning shadows to where curvatures occur or very sharp curves. Although this really would be best done in wpf, not winforms.

The links below are not for winforms but wpf. I just want to show you. The images used on the pages don't do wpf any justice.


 
DO NOT call CreateGrapgics. If you want to draw on a control then handle the Paint event of that control and use the Graphics object it provides. Whenever you want to change the drawing, call Invalidate on the control and the Paint event will be raised.
 
Back
Top Bottom