REM Electric discharge texture
REM CR 2007
 
cls
sync on
 
REM *** PARAMETERS - play with these to get the effect you want ***
rem all parameters need to be positive integers
 
rem size = size of image
size=4
rem blur = how blurred the bitmap is. Better to use even values
blur=4
rem spread = how far the electric arc spreads out
spread=2
rem cycle toggles color cycling (1 = cycle, 0 = no cycle)
cycle=1
 
 
rem calculate number of particles and set up arrays
num=spread+15*size^2
dim x(num)
dim y(num)
 
rem set initial positions of particles
for a=1 to num
	x(num)=32*size
	y(num)=rnd(32*size)
next a
 
rem create bitmap where the image will be drawn
create bitmap 1,64*size,64*size
 
REM MAIN LOOP
do
	set current bitmap 1
	rem move, draw electric particles
	for a=1 to num
		y(num)=y(num)+1
		x(num)=x(num)+rnd(spread*2)-spread
		if y(num)>size*64
			x(num)=32*size
			y(num)=0
		endif
		color=rnd(10)*20
		rem cycle colours
		if cycle then inc ang
		ink rgb(155+100*sin(ang/20),155+100*sin(ang/40),155+100*cos(ang/20)),0
		rem draw the particle
		dot x(num),y(num)
	next a
 
	rem blur bitmap
	if blur>0 then blur bitmap 1,blur
 
	rem get the image
	get image 1,0,0,64*size,64*size
 
	rem paste image - but you can use it to texture an object if you want
	set current bitmap 0
	paste image 1,(screen width()/2)-32*size,(screen height()/2)-32*size
	sync
loop