DEF GRADIENT X,Y,W,H,C1,C2,VERTICAL
IF VERTICAL THEN SWAP W,H
VAR R1,G1,B1,R2,G2,B2
RGBREAD C1 OUT R1,G1,B1
RGBREAD C2 OUT R2,G2,B2
VAR I
FOR I=0 TO W-1
VAR N=I/(W-1)
VAR F=1-N
VAR R=R1*F+R2*N
VAR G=G1*F+G2*N
VAR B=B1*F+B2*N
IF VERTICAL THEN
GLINE X,Y+I,X+H-1,Y+I,RGB(R,G,B)
ELSE
GLINE X+I,Y,X+I,Y+H-1,RGB(R,G,B)
ENDIF
END
should be
DEF GRADIENT X%,Y%,W%,H%,C1%,C2%,VERTICAL%
'VERTICAL is really a boolean, so make it use the least amount of bits posible, making it an int
IF VERTICAL% THEN SWAP W%,H%'you can't put a pixel at a non - int position, so W and H should be ints
VAR R1%,G1%,B1%,R2%,G2%,B2%'RGB is always an int
RGBREAD C1% OUT R1%,G1%,B1%
RGBREAD C2% OUT R2%,G2%,B2%
VAR I%'Should be an int because it is always a whole number
FOR I=W-1 TO 0 STEP -1'12Me21
VAR N%=I%/(W%-1)
VAR F%=1-N%
VAR R%=R1%*F%+R2%*N%
VAR G%=G1%*F%+G2%*N%
VAR B%=B1%*F%+B2%*N%
IF VERTICAL% THEN
GLINE X%,Y%+I%,X%+H%-1,Y%+I%,RGB(R%,G%,B%)
ELSE
GLINE X%+I%,Y%,X%+I%,Y%+H%-1,RGB(R%,G%,B%)
ENDIF
END
should be a tad faster...