Efficiency of orthogonal line drawing in 2D

As a follow up of my flood algorithm question, I have worked today on drawing 2D lines that can only have a horizontal segment and a vertical one. The longest segment is the major one, drawn first, and a minor segment follows.

I’ve managed to code something and it checks against all of my examples, but it’s pretty long and convoluted (~ 60 lines of elm-formatted code for the toRectLine function). Would anyone have something to suggest for efficiency?

No worries if you don’t have time to check it out. I tried to add comments to everything ambiguous but it’s pretty long with the examples and all.

Thanks to the people who had a lightning-fast answer yesterday, the community is pretty cool around here :star_struck:

EDIT: did not work in practice so here is a (so far) working example even longer and more convoluted :expressionless:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.