Here are some functions I just put together, which can be used to draw ellipses which have up to four different colours. It has a line function which although needed by the ellipse function, can be used on its own. Both functions need the third function col_phase to transition between the colours smoothly.
Here is a very colourful example showing the average time to draw an ellipse:
sync on
ink rgb(255,255,255),0
start# = timer()
do
for d = 1 to 50
filledcircle(rnd(screen width()), rnd(screen height()), rnd(100), rnd(100), rnd(16777215), rnd(16777215), rnd(16777215), rnd(16777215))
inc c
next d
filledcircle(200,75,250,75,0,0,0,0)
inc c
center text 200,50,"Ellipses drawn: "+str$(c)
center text 200,80,"Average speed: "+str$((timer()-start#)/c,2)+" ms"
sync
loop
end
function filledcircle(x, y, w, h, col1, col2, col3, col4)
h# = h
w# = w
s# = w#/h#
r = w#/2
for d = 0-r to r
d# = d
r# = r
a# = asin(d#/r#)
ny = cos(a#)*r#/s#
col5 = col_phase(col1,col2,r*2,d+r)
col6 = col_phase(col3,col4,r*2,d+r)
fline(d+x,(0-ny)+y,d+x,ny+y,col5,col6)
next d
endfunction
function fline(x1#,y1#,x2#,y2#,col1,col2)
lock pixels
dx# = x2#-x1#
dy# = y2#-y1#
l# = max(abs(dx#),abs(dy#))
ix# = dx#/l#
iy# = dy#/l#
for a = 0 to int(l#)
nx = (ix#*a)+x1#
ny = (iy#*a)+y1#
dot nx,ny,col_phase(col1,col2,int(l#),a)
next a
unlock pixels
endfunction
function col_phase(col1, col2, div#, pos#)
r1# = rgbr(col1)
g1# = rgbg(col1)
b1# = rgbb(col1)
r2# = rgbr(col2)
g2# = rgbg(col2)
b2# = rgbb(col2)
r# = (((r2#-r1#)/div#)*pos#)+r1#
g# = (((g2#-g1#)/div#)*pos#)+g1#
b# = (((b2#-b1#)/div#)*pos#)+b1#
col = rgb(r#,g#,b#)
endfunction col
if you do not have the matrix_utils plugin, then you will need to put this function in at the bottom as well:
function max(a#,b#)
if b# > a# then a# = b#
endfunction a#
On my slow computer, it only takes about 2ms for each ellipse.