News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

TV Static / Black & White Random Noise

Started by kevin, March 12, 2008, 11:39:47 PM

Previous topic - Next topic

kevin

TV Static / Black & White Random Noise

 This snippets draws a full screen random static pattern.  


PlayBASIC Code: [Select]
   Width=GetScreenWidth()*2
height=1

Img_Cache=NewFxImage(Width,Height)


Dim Palette(255)
For lp=0 to 255
Palette(lp)=rgb(lp,lp,lp)
next



Do

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

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






kevin

#1
 Colour Static

PlayBASIC Code: [Select]
   Width=GetScreenWidth()*2
height=1

Img_Cache=NewFxImage(Width,Height)

Do

Rendertoimage Img_Cache
SeedbufferRead=Point(0,0)
Lockbuffer
For ylp=0 to Height-1
For xlp=0 to Width-1
FastDot xlp,ylp,rnd($ffffff)
next
next
unLockbuffer

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

Sync
loop






Adaz

Quote from: kevin on March 12, 2008, 11:44:05 PM
Colour Static
BBC appeared here but only for some seconds, and no sound, why? :)

Ádáz

Hungary

kevin

#3
  Here's a version with full screen fading.


PlayBASIC Code: [Select]
   Width=GetScreenWidth()*2
height=1
Img_Cache=NewFxImage(Width,Height)


Dim Palette(255)

Do

; Calc fade level
FadeLevel=50+CosRadius(FadeANGLE#,50)
FadeANGLE#=WrapAngle(FadeANGLE#,2)


; Seed Faded palette
For lp=0 to 255
C=rgb(lp,lp,lp)
Palette(lp)=rgbfade(c,FadeLevel)
next

; 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

; copy ranom strips to the output buffer
rendertoscreen
lockbuffer
Width2=Width-GetScreenWidth()
For Ylp=0 to GetScreenHeight()-1
drawimage img_cache,-rnd(Width2),ylp,0
next
unlockbuffer


Sync
loop





kevin



PlayBASIC Code: [Select]
explicit true

local bitwidth=2

local PixelStepX = 8*BitWIdth

local IMage_Frags = NewfxImage(8*bitwidth,256)
rendertoimage Image_Frags
cls $008044
local lp
for lp =0 to 256*4
dotc rnd(8*Bitwidth),lp and 255,$00ffffff
next
rendertoscreen
local Screen = newfximage(getScreenWidth(),GetScreenheight())

Setfps 100
Do

rendertoimage Screen
// cls $102030


lockbuffer
local ThisRGB=point(0,0)
local xlp,ylp,xpos,x1,x2
for ylp=0 to (getsurfaceheight()-1) step BitWidth
Xpos=0
for xlp=0 to (getsurfacewidth()/PixelStepX)-1
local ThisByte = (ThisByte+xlp) and 255
copyrect IMage_Frags,0,ThisByte,PixelStepX,ThisByte+1,Screen, Xpos,Ylp
Xpos+=PixelStepX
next
if BitWidth>0
X1 =0
X2= getSurfaceWidth()
local copyrow
for copyrow =1 to BitWidth
copyrect screen,x1,ylp,x2,ylp+1,screen,0,ylp+copyrow

next
endif
next
unlockbuffer

rendertoscreen
drawimage screen,0,0,false
// drawimage Image_Frags,600,0,false

text 10,10, "Channel:"+str$(ThisByte)

sync

loop