Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include once "fbgfx.bi"
- 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 )
- const PI_180 = 3.141592/180
- type pixel as ubyte
- const TransColor = 0
- dim as integer nx=any, ny=any, mx=any, my=any, col=any
- dim as single nxtc=any, nxts=any, nytc=any, nyts=any
- dim as integer sw2=any, sh2=any, dw=any, dh=any
- dim as single tc=any,ts=any
- dim as pixel ptr dstptr=any, srcptr=any
- dim as integer xput=any, yput=any, startx=any, endx=any, starty=any, endy=any
- if dst = 0 then
- dstptr = screenptr
- screeninfo dw,dh
- else
- dstptr = cast( pixel ptr, dst+1)
- dw = dst->width
- dh = dst->height
- end if
- srcptr = cast( pixel ptr, src+1)
- sw2 = src->width\2: positx -= sw2
- sh2 = src->height\2: posity -= sh2
- tc = cos( -angle * pi_180 )
- ts = sin( -angle * pi_180 )
- xput = (src->width * zoomx)
- yput = (src->height * zoomy)
- startx = -xput
- endx = src->width + xput
- starty = -yput
- endy = src->height + yput
- for y as integer = starty to endy
- yput = y + posity
- if yput>-1 and yput<dh then
- ny = y - sh2
- nytc = (ny * tc) / zoomy
- nyts = (ny * ts) / zoomy
- for x as integer = startx to endx
- xput = x+positx
- if xput>-1 and xput<dW then
- nx = x - sw2
- nxtc = (nx * tc) / zoomx
- nxts = (nx * ts) / zoomx
- mx = (nxtc - nyts) + sw2
- my = (nytc + nxts) + sh2
- if mx>-1 and my>-1 and mx<src->width and my<src->height then
- col = *cast(pixel ptr, cast(ubyte ptr, srcptr) + my * src->pitch + mx * src->bpp )
- if col<>TransColor then
- if dst = 0 then
- dstptr[ (yput * dw ) + xput ] = col
- else
- *cast(pixel ptr, cast(ubyte ptr, dstptr) + yput * dst->pitch + xput * dst->bpp) = col
- end if
- end if
- end if
- end if
- next
- end if
- next
- end sub
- screenres 640,480
- dim as fb.image ptr pBlock = ImageCreate(128,128)
- dim as fb.image ptr pBack = ImageCreate(640,480)
- line pBlock,(0,0)-(127,127),1,bf
- for N as single = 0 to 6.2 step .62
- circle pBlock,(64-sin(N)*48,64-cos(N)*48),8,0,,,,f
- next N
- circle pBlock,(12,12),10,0,,,,f: circle pBlock,(115,12),10,0,,,,f
- circle pBlock,(12,115),10,0,,,,f: circle pBlock,(115,115),10,0,,,,f
- circle pBlock,(64,64),56,10
- line pBlock,(14,14)-step(100,100),12,b,&h5555
- for iX as integer = -1 to 1
- for iY as integer = -1 to 1
- draw string pBlock,(41+iX,60+iY),"Mysoft",14
- next iY
- next iX
- draw string pBlock,(41,60),"Mysoft",0
- put(100,100),pBlock,pset
- var pPix = cast(ubyte ptr,pBack+1)
- for N as integer = 0 to (640*480)-1
- pPix[N] = 128+rnd*115
- next N
- do
- dim as integer iAngle = (timer*60) mod 360
- dim as single fScale = 1+abs(-3+(((timer*55) mod 600)/100))
- screenlock
- put(0,0),pBack,pset
- rotozoom8(,pBlock,320,240,iAngle,fScale,fScale)
- screenunlock
- sleep 5,1
- loop until len(inkey$)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement