Found this by searching
setVirtualResolution(640,480)
dim circles[100]
t = getMilliseconds()
for i = 1 to 100
circles[i] = createSprite(getImageCircle(random(8,128), 255,255,255))
r = random(0, 255)
g = random(0, 255)
b = random(0, 255)
setSpriteColor(circles[i], r, g, b, 255)
setSpritePosition(circles[i], random(0,640), random(0,480))
next i
t = getMilliseconds() - t
do
if getrawkeypressed(32) = 1
for i = 1 to 100
r = random(0, 255)
g = random(0, 255)
b = random(0, 255)
setSpriteColor(circles[i], r, g, b, 255)
setSpritePosition(circles[i], random(0,704)-64, random(0,544)-64)
next i
endif
print(t)
sync()
loop
function getImageCircle(radius, red, green, blue)
mem = 1
diameter = radius+radius
memSize = diameter*diameter*4 + 12
createMemblock(mem, memSize)
// 12-byte Header
setMemblockInt(mem, 0, diameter)
setMemblockInt(mem, 4, diameter)
setMemblockInt(mem, 8, 32)
//Color value
base = (blue*65536) + (green*256) + red
color = (255*16777216) + base
// Unfortunately, we have to fill the entire image
// to prevent random artifacts from showing up.
for y = 0 to diameter-1
for x = 0 to diameter-1
pos = (y*diameter + x)*4 + 12
setMemblockInt(mem, pos, 0)
next x
next y
cx = radius-1
cy = radius-1
x = radius-1
y = -1
t# = 0
while x > y
inc y
cur_dist# = E2DC_Distance#(radius, y)
if cur_dist# <= t# then dec x
a = 127*cur_dist# : alpha1 = (a*16777216) + base
a = 127 - a : alpha2 = (a*16777216) + base
// octant 1
E2DC_MemDot(mem, cx-y, cy-x, color)
E2DC_MemDot(mem, cx-y, cy-x-1, alpha2)
E2DC_MemDot(mem, cx-y, cy-x+1, alpha1)
// octant 2
E2DC_MemDot(mem, cx-x, cy-y, color)
E2DC_MemDot(mem, cx-x-1, cy-y, alpha2)
E2DC_MemDot(mem, cx-x+1, cy-y, alpha1)
// octant 3
E2DC_MemDot(mem, cx-x, cy+y, color)
E2DC_MemDot(mem, cx-x-1, cy+y, alpha2)
E2DC_MemDot(mem, cx-x+1, cy+y, alpha1)
// octant 4
E2DC_MemDot(mem, cx-y, cy+x, color)
E2DC_MemDot(mem, cx-y, cy+x+1, alpha2)
E2DC_MemDot(mem, cx-y, cy+x-1, alpha1)
// octant 5
E2DC_MemDot(mem, cx+y, cy+x, color)
E2DC_MemDot(mem, cx+y, cy+x+1, alpha2)
E2DC_MemDot(mem, cx+y, cy+x-1, alpha1)
// octant 6
E2DC_MemDot(mem, cx+x, cy+y, color)
E2DC_MemDot(mem, cx+x+1, cy+y, alpha2)
E2DC_MemDot(mem, cx+x-1, cy+y, alpha1)
// octant 7
E2DC_MemDot(mem, cx+x, cy-y, color)
E2DC_MemDot(mem, cx+x+1, cy-y, alpha2)
E2DC_MemDot(mem, cx+x-1, cy-y, alpha1)
// octant 8
E2DC_MemDot(mem, cx+y, cy-x, color)
E2DC_MemDot(mem, cx+y, cy-x-1, alpha2)
E2DC_MemDot(mem, cx+y, cy-x+1, alpha1)
t# = cur_dist#
endwhile
img = createImageFromMemblock(mem)
deleteMemblock(mem)
endfunction img
function E2DC_MemDot(id, x, y, color)
width = getMemblockInt(id, 0)
pos = (y*width + x)*4 + 12
setMemblockInt(id, pos, color)
endfunction
function E2DC_Distance#(a, b)
real# = sqrt(a*a - b*b)
d# = ceil(real#) - real#
endfunction d#