Points in Line

  • 16 years ago

    Does anyone know how to get an array of points that is calculated in the graphics.drawline?  You give it 2 points, and it calculates every point that will be on this line and draws the line with the specific color and thickness.  I need those individual points that it calculates.


    Just in case anyone is wondering, the reason I need to have this array is because, in my program, I am offering a brush tool to paint with.  The drawing code is called on the mousemove of a picturebox.  As you may know, the mousemove event isnt raised for every pixel movement of the mouse if the mouse is drug fast.  


    My current fix for this is to draw a line with the thickness of the brush tool from the last point to the current point, this works fine for a solid color brush (with a little fix).  The problem is that I also have the option to add a hatch or gradient fill to the brush.  you cant draw a line with a hatch or gradient style.  so for example if the brush style is a 10x10 square, with the hatch mode selected, it wont be a continuous "line of hatch pattern" if the mouse is drug fast, but a series of broken squares that are placed wherever the mouse happens to be when the mousemove event is finally fired.  I plan to loop through this array of points and draw the hatch filled square centered over each point.


    If I havent made myself clear enough, open up MS Paint, selectet the brush tool, and draw a line really fast.  You should see a bunch of connected straight lines with a change in direction whenever the mousemove event is raised even if you drug the mouse in a curve pattern.  That is because the mosuemove event isnt fired every pixel the mouse is moved.  I think MS paint use my same method for fixing this by drawing lines (not filling rctangles) as i did.  But what am i supposed to do with gradients and hatches?

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.” - Antoine de Saint Exupéry