문제

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