08-29-2023, 12:47 AM
Such a long time since I've done this kind of stuff, I don't have much confidence in my struggled result.
Is this the right way to draw a line with PSET ???
Is this the right way to draw a line with PSET ???
Code: (Select All)
SCREEN _NEWIMAGE(641, 201, 32)
SUB MyLine(x1%, y1%, x2%, y2%)
' y% = m# * x% + c#
xd% = x2% - x1%
yd% = y2% - y1%
m# = yd%/xd%
c# = y2% - x2% * m#
IF xd% >= yd% THEN FOR i = x1% to x2%: PSET(i, m# * i + c#) : NEXT i
IF xd% < yd% THEN FOR i = y1% to y2%: PSET((i - c#)/m#, i) : NEXT i
END SUB
FOR X = 0 TO 640 step 10
MyLine(0,0,X,200)
NEXT X
FOR Y = 0 TO 200 step 5
LINE (0,0)-(640, Y), _RGB(255,255,0)
NEXT X