Hi, I was playing around with line drawing today, and was not having fun.
I have lines to draw and the data comes as co-ordinates for the start and end of a line. No problem, I thought, just do x2-x1 and y2-y1 to get the width and height and then correct them if they are negative.
Which works OK up to a point (pun intended

Again, it's not that simple, because vertically you do not want the height to have 1 added or the line goes at an angle incorrectly. And it gets even worse, because the component (width or height) which you need to add 1 to changes with the angle of your line.
(Implemented as 'LineXY()')
Anyway, this is the code I use for drawing lines now:
Code: Select all
Procedure MyLine(x1.w, y1.w, x2.w, y2.w)
DefType.l w
DefType.l h
; Draw line here with stupid PB Line command syntax
w = x2 - x1 : h = y2 - y1
If wh
w=w+1
Else
h=h+1
If w=h : w=w+1 : EndIf
EndIf
Line(x1, y1, w, h)
EndProcedure

--
It's not minimalist - I'm increasing efficiency by reducing input effort.