sync on
sync rate 7
 
make2images()
 
do
  pixelize(1,2)
  wait key
  pixelize(2,1)
  wait key
loop
 
 
function pixelize(img1,img2)
  sync on
  resstep=9
  fadein=0
  fadeimage=img1
  paste image fadeimage,0,0
  sync
 
  while fadein<>2
    if (resstep<256) AND (resstep>8)
      if resstep=9 then resstep=8
      paste image fadeimage,0,0
      for countx=0 to 800/resstep step 1
        x=countx*resstep
        for county=0 to 600/resstep step 1
 
          `simple and fast
          y=county*resstep
          ink point(x+(resstep/2),y+(resstep/2)),rgb(0,0,0)
          box x,y,x+resstep,y+resstep
 
          `better, as it averages some pixels, but slower
          remstart
          currcolor=point(x,y)
          for countpixx=0 to (resstep/(resstep/8)) step 1
            pixx=countpixx*(resstep/8)
            for countpixy=0 to (resstep/(resstep/8)) step 1
              pixy=countpixy*(resstep/8)
              pointclr=point(x+pixx,y+pixy)
              currcolor=rgb((rgbr(pointclr)+rgbr(currcolor))/2,(rgbg(pointclr)+rgbg(currcolor))/2,(rgbb(pointclr)+rgbb(currcolor))/2)
            next pixy
          next pixx
          ink currcolor,rgb(0,0,0)
          box x,y,x+pixx,y+pixy
          remend
 
        next y
      next x
    select fadein
      case 0 : resstep=(resstep*2) : endcase
      case 1 : resstep=(resstep/2) : endcase
    endselect
    sync
  else
    select fadein
      case 0
        fadeimage=img2
        fadein=1
        resstep=(resstep/2)
      endcase
      case 1
        paste image fadeimage,0,0
        sync
        fadein=2
      endcase
    endselect
  endif
endwhile
endfunction
 
function make2images()
 
autocam off
color backdrop 0
position camera 0,0,0
for image=1 to 2
for n=1 to 500
if image=1 then make object box n,rnd(10)+1,rnd(10)+1,rnd(10)+1
if image=2 then make object sphere n,rnd(7)+1,20,20
color object n,rnd(1000000000)
position object n,rnd(100)-50,rnd(100)-50,rnd(100)+50
next n
sync
get image image,0,0,screen width(),screen height(),1
delete objects 1,500
next image
 
endfunction