I started work on some custom drawing functions a while back, using memblocks.
remstart
-------------------------------------------------------------------
program name: Memblock Bitmap Functions
-------------------------------------------------------------------
written by: Oli Burt
date: 6th April 2009 - 9th April 2009
-------------------------------------------------------------------
comments:
-------------------------------------------------------------------
remend
set display mode 640,480,32
hide mouse
sync on
make_memblock_bmp(1,640,480,32)
fill_memblock_bmp(1,rgb(255,255,255))
wirebox_memblock_bmp(1,200,100,300,250,rgb(255,0,0))
line_memblock_bmp(1,20,300,400,260,rgb(0,255,0))
make bitmap from memblock 0,1
sync
wait key
delete memblock 1
end
`--------------
` Functions
`--------------
Function box_memblock_bmp(memblock,ax,ay,bx,by,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Edit Memblock
for y = ay to by
for x = ax to bx
write memblock dword memblock,12+x*byte_depth+y*width*byte_depth, colour
next x
next x
Endfunction
`//
Function dot_memblock_bmp(memblock,x,y,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Edit Memblock
write memblock dword memblock,12+x*byte_depth+y*width*byte_depth, colour
Endfunction
`//
Function fill_memblock_bmp(memblock,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Edit Memblock
for y = 0 to height-1
for x = 0 to width-1
write memblock dword memblock,12+x*byte_depth+y*width*byte_depth, colour
next x
next y
Endfunction
`//
Function line_memblock_bmp(memblock,ax,ay,bx,by,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Get Line Length (Hypotenuse of x/y triangle)
xdif= ax-bx
ydif= ay-by
hyp= sqrt(xdif*xdif + ydif*ydif)
`Edit Memblock
for pass = 1 to hyp
factor#= pass/(hyp+.0)
x= ax - int((ax-bx)*factor#+.5)
y= ay - int((ay-by)*factor#+.5)
write memblock dword memblock,12+x*byte_depth+y*width*byte_depth, colour
next pass
Endfunction
`//
Function make_memblock_bmp(memblock,width,height,bit_depth)
if memblock exist(memblock) = 0
byte_depth= bit_depth/8
make memblock memblock,12+width*height*byte_depth^2
`Header (12 bytes)
write memblock dword memblock,0,width
write memblock dword memblock,4,height
write memblock dword memblock,8,bit_depth
endif
Endfunction
`//
Function point_memblock_bmp(memblock,x,y)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Read From Memblock
colour = memblock dword(memblock,12+x*byte_depth+y*width*byte_depth)
Endfunction colour
`//
Function make_reflect_memblock_bmp(memblock_b,memblock_a,colour)
`Read Header
width= memblock dword(memblock_a,0)
height= memblock dword(memblock_a,4)
byte_depth= memblock dword(memblock_a,8)/8
`Make Reflection Memblock
make memblock memblock_b,12+width*height*byte_depth^2
`Write Header (12 bytes)
write memblock dword memblock_b,0,width
write memblock dword memblock_b,4,height
write memblock dword memblock_b,8,bit_depth
`Reverse-Copy Memblock
for y = 0 to height-1
for x = 0 to width-1
copy= memblock dword(memblock_a,12+x*byte_depth+(height-1-y)*width*byte_depth)
write memblock dword memblock_b,12+x*byte_depth+y*width*byte_depth, copy
next x
next y
Endfunction
`//
Function wirebox_memblock_bmp(memblock,ax,ay,bx,by,colour)
`Read Header
width= memblock dword(memblock,0)
height= memblock dword(memblock,4)
byte_depth= memblock dword(memblock,8)/8
`Edit Memblock
for x = ax to bx
write memblock dword memblock,12+x*byte_depth+ay*width*byte_depth, colour
write memblock dword memblock,12+x*byte_depth+by*width*byte_depth, colour
next x
for y = ay to by
write memblock dword memblock,12+ax*byte_depth+y*width*byte_depth, colour
write memblock dword memblock,12+bx*byte_depth+y*width*byte_depth, colour
next y
Endfunction
`//
That might be a bit advanced for you to understand just yet but the functions are pretty easy to use and much faster than the default drawing commands, if I remember correctly.