Advertisement
Mysoft

Untitled

Oct 5th, 2016
645
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include once "fbgfx.bi"
  2.  
  3. sub rotozoom8( dst as FB.IMAGE ptr = 0, src as FB.IMAGE ptr, positx as integer, posity as integer, angle as integer, zoomx as single, zoomy as single )
  4.  
  5.   const PI_180 = 3.141592/180
  6.   type pixel as ubyte
  7.   const TransColor = 0
  8.  
  9.   dim as integer nx=any, ny=any, mx=any, my=any, col=any
  10.   dim as single nxtc=any, nxts=any, nytc=any, nyts=any
  11.   dim as integer sw2=any, sh2=any, dw=any, dh=any
  12.   dim as single tc=any,ts=any
  13.   dim as pixel ptr dstptr=any, srcptr=any
  14.   dim as integer xput=any, yput=any, startx=any, endx=any, starty=any, endy=any
  15.  
  16.   if dst = 0 then
  17.     dstptr = screenptr
  18.     screeninfo dw,dh
  19.   else
  20.     dstptr = cast( pixel ptr, dst+1)
  21.     dw = dst->width
  22.     dh = dst->height
  23.   end if
  24.  
  25.   srcptr = cast( pixel ptr, src+1)
  26.  
  27.   sw2 = src->width\2: positx -= sw2
  28.   sh2 = src->height\2: posity -= sh2
  29.   tc = cos( -angle * pi_180 )
  30.   ts = sin( -angle * pi_180 )  
  31.   xput = (src->width  * zoomx)
  32.   yput = (src->height * zoomy)  
  33.   startx = -xput
  34.   endx = src->width + xput
  35.   starty = -yput
  36.   endy = src->height + yput    
  37.  
  38.   for y as integer = starty to endy
  39.     yput = y + posity    
  40.     if yput>-1 and yput<dh then
  41.       ny = y - sh2
  42.       nytc = (ny * tc) / zoomy
  43.       nyts = (ny * ts) / zoomy      
  44.       for x as integer = startx to endx
  45.         xput = x+positx
  46.         if xput>-1 and xput<dW then
  47.           nx = x - sw2
  48.           nxtc = (nx * tc) / zoomx
  49.           nxts = (nx * ts) / zoomx                    
  50.           mx = (nxtc - nyts) + sw2
  51.           my = (nytc + nxts) + sh2                    
  52.           if mx>-1 and my>-1 and mx<src->width and my<src->height then
  53.             col = *cast(pixel ptr, cast(ubyte ptr, srcptr) + my * src->pitch + mx * src->bpp )
  54.             if col<>TransColor then
  55.               if dst = 0 then
  56.                 dstptr[ (yput * dw ) + xput ] = col
  57.               else
  58.                 *cast(pixel ptr, cast(ubyte ptr, dstptr) + yput * dst->pitch + xput * dst->bpp) = col
  59.               end if
  60.             end if
  61.           end if                    
  62.         end if
  63.       next
  64.     end if
  65.   next
  66.  
  67. end sub
  68.  
  69. screenres 640,480
  70.  
  71. dim as fb.image ptr pBlock = ImageCreate(128,128)
  72. dim as fb.image ptr pBack = ImageCreate(640,480)
  73.  
  74. line pBlock,(0,0)-(127,127),1,bf
  75. for N as single = 0 to 6.2 step .62
  76.   circle pBlock,(64-sin(N)*48,64-cos(N)*48),8,0,,,,f
  77. next N
  78. circle pBlock,(12,12),10,0,,,,f: circle pBlock,(115,12),10,0,,,,f
  79. circle pBlock,(12,115),10,0,,,,f: circle pBlock,(115,115),10,0,,,,f
  80.  
  81. circle pBlock,(64,64),56,10
  82. line pBlock,(14,14)-step(100,100),12,b,&h5555
  83. for iX as integer = -1 to 1
  84.   for iY as integer = -1 to 1
  85.     draw string pBlock,(41+iX,60+iY),"Mysoft",14
  86.   next iY
  87. next iX
  88. draw string pBlock,(41,60),"Mysoft",0
  89.  
  90. put(100,100),pBlock,pset
  91.  
  92. var pPix = cast(ubyte ptr,pBack+1)
  93. for N as integer = 0 to (640*480)-1
  94.   pPix[N] = 128+rnd*115
  95. next N
  96.  
  97.  
  98. do    
  99.  
  100.   dim as integer iAngle = (timer*60) mod 360
  101.   dim as single fScale = 1+abs(-3+(((timer*55) mod 600)/100))
  102.  
  103.   screenlock
  104.   put(0,0),pBack,pset
  105.   rotozoom8(,pBlock,320,240,iAngle,fScale,fScale)
  106.   screenunlock
  107.  
  108.   sleep 5,1  
  109.  
  110. loop until len(inkey$)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement