I'm trying to make use of the following algorithm: http://www.skytopia.com/project/articles/compsci/clipping.html

But for my special case, I don't have a line that crosses the rectangle 2 times, but it starts in the center of the rectangle and only crosses it one single time.

Using the algorithm above I want to get the single intersection point for drawings on a canvas.

Problem: a canvas does not have a normal coordinate space where Y grows to the top, but Y grows to the bottom.

What would I have to change in order to "mirror" the y-axis and make it work in a canvas coordinate system?

有帮助吗?

解决方案

Indeed the algorithm can be just ported as it is for using with canvas. I had some typo in the algor and after elemination it just works as expected.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top