Main Menu

Cross Fade With Static

Started by kevin, September 14, 2008, 12:01:53 PM

Previous topic - Next topic

kevin

Cross Fade With Static

    This snippet cross fades between a picture and a TV static pattern.



Similar Examples

  TV Static / Black & White Random Noise


  Attached code for PB V1.63 / PB1.64

kevin

#1
  This version of the code is for PlayBasicFX.  It requires the media from the version attached above.

PlayBASIC Code: [Select]
   setfps 60

sw=getScreenWidth()
sh=getScreenHeight()


// Make the backdrop image
Img_Logo=LoadNewimage("uwlogo.bmp")

BackDrop=New3Dimage(sw,sh)
iw=GetImageWidth(img_logo)
ih=GetImageHeight(img_logo)
c1=rgb(0,02,200)
c2=rgb(200,402,50)
shadebox 0,0,sw,sh,c1,c2,c1,c2
DrawImage Img_logo, (sw/2)-(iw/2),(sh*0.4)-(ih/2),true
copyrect 0,0,0,sw,sh,backdrop,0,0


// Static image strip
Width=sw*2
height=1
Img_Cache=NewFXImage(Width,Height)

// static palette
Dim Palette(255)
; Seed Faded palette
For lp=0 to 255
Palette(lp)=rgb(lp,lp,lp)
next

Do
; Calc fade level
FadeLevel=50+CosRadius(FadeANGLE#,50.0)
FadeANGLE#=WrapAngle(FadeANGLE#,1.5)

; Randomize the image strip
Rendertoimage Img_Cache
SeedbufferRead=Point(0,0)
Lockbuffer
For ylp=0 to Height-1
For xlp=0 to Width-1
FastDot xlp,ylp,Palette(rnd(255))
next
next
unLockbuffer


Rendertoimage 0
lockbuffer
inkmode 1
Width2=Width-GetScreenWidth()
For Ylp=0 to GetScreenHeight()-1
drawimage img_cache,-rnd(Width2),ylp,0
next
unlockbuffer

; draw backdrop blended with the static image
drawAlphaimage BackDrop,0,0,FadeLevel/100.0,false

Sync
loop