Whoo. I got there in the end.
Ok, this is going to need an explanation.
First, a triangle with a flat top or bottom is easy to draw - just take my word for it

Secondly, a triangle without a flat top or bottom can be broken into two triangles, one with a flat top and the other with a flat bottom.
Next, any polygon with three sides or more can be drawn with 1 or more triangles - this is the basis of the 3D we use every day.
If you look through the code, you'll see that everything is arranged as I've detailed above. I've used the box command because it's faster at drawing horizontal lines than the line command.
sync on
FilledTrapezoid(20,20, 50,30, 60,60, 30,40)
sync
wait key
end
function FilledTrapezoid(x0,y0,x1,y1,x2,y2,x3,y3)
FilledTriangle(x0,y0,x1,y1,x2,y2)
FilledTriangle(x0,y0,x2,y2,x3,y3)
endfunction
function FilledTriangle(x0,y0,x1,y1,x2,y2)
local tx as integer
local ty as integer
local NewX as integer
` Sort the points so that they are in order of their y coords
if y1 < y0
ty=y1 : y1=y0 : y0=ty
tx=x1 : x1=x0 : x0=tx
endif
if y2 < y0
ty=y2 : y2=y0 : y0=ty
tx=x2 : x2=x0 : x0=ty
endif
if y2 < y1
ty=y2 : y2=y1 : y1=ty
tx=x2 : x2=x1 : x1=tx
endif
if y0 = y1
FlatTopTriangle(x0,y0,x1,y1,x2,y2)
else
if y1 = y2
FlatBottomTriangle(x0,y0,x1,y1,x2,y2)
else
NewX=x0+( ( ((y1+0.0)-y0) * ((x2+0.0)-x0) ) / ((y2+0.0)-y0) )+0.5
FlatBottomTriangle(x0,y0,x1,y1,NewX,y1)
FlatTopTriangle(x1,y1,NewX,y1,x2,y2)
endif
endif
endfunction
function FlatBottomTriangle(x0,y0,x1,y1,x2,y2)
local dxy_left as float
local dxy_right as float
local xs as float
local xe as float
local y as integer
if x2 > x1 then tx=x1 : x1=x2 : x2=tx
dxy_left=((x2+0.0)-x0)/((y2+0.0)-y0)
dxy_right=((x1+0.0)-x0)/((y1+0.0)-y0)
xs=x0+0.5
xe=x0+1.0
for y=y0 to y1
box xs,y,xe,y+1
xs=xs+dxy_left
xe=xe+dxy_right
next y
endfunction
function FlatTopTriangle(x0,y0,x1,y1,x2,y2)
local dxy_left as float
local dxy_right as float
local xs as float
local xe as float
local y as integer
if x1 < x0 then tx=x0 : x0=x1 : x1=tx
dxy_left=((x2+0.0)-x0)/((y2+0.0)-y0)
dxy_right=((x2+0.0)-x1)/((y2+0.0)-y1)
xs=x0+0.5
xe=x1+1.0
for y=y0 to y2
box xs,y,xe,y+1
xs=xs+dxy_left
xe=xe+dxy_right
next y
endfunction