paint - Straight Line Equation between two points -


I need to paint the line that combines two points.

I am doing it in Java, I get two points in the form of parameters and I have to calculate that the direct line between them is inside the black shape.

I developed my own solution using the straight line equation, but my result was "professional" program (like GIMP or MS Paint).

Here is an example that I want to:

But my algorithm does this:

* Green color is out of figure and this is not possible.

Any thoughts? Anyone knows what code is using this in the "professional" application?

Thank you! Daniel.

Edit: Images

It looks like you're sorting instead of the intersection Hard to see on those small black ink splotches to the nearest pixel. Can you post code?


Comments