set display mode 1024, 768, 32
sync on
sync rate 100
hide mouse
 
mag as double float
c as double float
 
width=screen width()
height=screen height()
 
centerx=width/2
centery=height/2
 
type xy
 x as integer
 y as integer
endtype
 
 
dim cur (101,101) as xy
 
dim cur2 (101,101) as dword
 
 
lock pixels
 
pix as dword
 
dr as float
dg as float
db as float
 
r=255
g=255
b=255
n=65
 
dr=(r-128.0)/n
dg=(g-168.0)/n
db=(b-144.0)/n
 
for x=centerx-50 to centerx+50
  for y=centery-50 to centery +50
    xpos=x-centerx
    ypos=y-centery
    d=sqrt(xpos*xpos+ypos*ypos)
 
    xpos1=x-centerx+15
    ypos1=y-centery+15
    d1=sqrt(xpos1*xpos1+ypos1*ypos1)+25
 
    if d<50 then dot x,y,rgb(255-(d1*dr),255-d1*dg,255-d1*db)
  next y
next x
unlock pixels
 
 
 
get image 2, centerx-50, centery-50, centerx+50, centery+50, 1
make memblock from image 1,2
 
s=get memblock size(1)-12
 
 
for a=4 to s step 4
  pix= memblock dword(1,a)
  pix=pix && 0x99FFFFFF
  write memblock dword 1,a,pix
next a
make image from memblock 2,1
 
 
 
 
lock pixels
 
for x=1 to 1024
for y=1 to 768
  dot x,y, rgb(x mod 255,y mod 255,rnd(255))
next y
next x
 
text 300, 300, "magnify"
 
 
 
for x=centerx-50 to centerx+50
  for y=centery-50 to centery +50
    xpos=x-centerx
    ypos=y-centery
    d=sqrt(xpos*xpos+ypos*ypos)
    if d<40
      mag=.66
`      dot x,y,rgb(255,255,255)
    endif
    if d>=40 and d<50
      c=d-40 `1-10
      c=c/100
      mag=c+.66
      `if c>126 then mag=(c-127)/32+1 else mag=c/255+0.5
`      dot x,y, rgb(c,c,c)
    endif
    if d>=50
`      dot x,y,rgb(127,127,127)
      mag=1.0
    endif
 
    dx1=xpos/mag
    dy1=ypos/mag
 
    dx2=dx1-xpos + 128
    dy2=dy1-ypos + 128
 
  `  dot x,y,rgb(dx2,dy2,127)
    cur(xpos+50,ypos+50).x=dx1-xpos
    cur(xpos+50,ypos+50).y=dy1-ypos
  next y
next x
 
unlock pixels
 
 
get image 3, 1,1, 1023, 767, 1
 
 
make object cube 1, 3
make object plain 2, 40, 30
position object 2, 0,0,25
position object 1, 2.5,5,20
autocam off
position camera 0,0,0
point camera 0,0,50
 
 
color object 1, rgb(255,255,0)
texture object 2, 3
 
ink rgb(192, 162, 100), 0
do
 inc r
 rotate object 1, r, r, r
 
 x=mousex()
 y=mousey()
 
 if x<50 then x=50
 if y<50 then y=50
 if x> width-50 then x=width-50
 if y> height-50 then y=height-50
 
 get image 1, x-50, y-50, x+50, y+50, 1
 
 lock pixels
   for i = x-50 to x+50
     for j= y-50 to y+50
        dx1=i-cur(i-x+50,j-y+50).x
        dy1=j-cur(i-x+50,j-y+50).y
        if dx1>0 and dx1<width and dy1>0 and dy1<height
          cur2(i+50-x,j+50-y)= point(dx1,dy1)
        else
        cur2(i+50-x,j+50-y)=0
        endif
     next j
   next i
 
 
   for i = x-50 to x+50
     for j= y-50 to y+50
        if i>0 and i<width and j>0 and j<height then dot i,j,cur2(i-x+50,j-y+50)
     next j
   next i
unlock pixels
 
 paste image 2, x-50, y-50, 1
 
circle x,y, 49
box x-5, y+50, x+5, y+125, rgb(192, 162, 100), rgb(153, 129, 80), rgb(255, 255, 255), rgb(192, 162, 100)
 
 
 sync
 
 loop