Create nice images for background...
Posted: Sun Nov 13, 2016 12:16 pm
I'd like to create random images for banners etc. which may look like one of the following examples:

My first attempt generates thousands of lines, but the parameters of the waves are totally uncontroled, so the chaotic results are far away from the target...
So I am interested if someone will be able to create nicer results?

My first attempt generates thousands of lines, but the parameters of the waves are totally uncontroled, so the chaotic results are far away from the target...
So I am interested if someone will be able to create nicer results?
Code: Select all
#X=1600
#Y=400
#count=360
Procedure xRandom(n)
Protected x
Repeat
x=Random(n)-n>>1
Until x<-n>>3 Or x>n>>3
ProcedureReturn x
EndProcedure
Procedure showwave(col,start.f,frequenz.f,amplitude.f,shiftx.f,shifty.f,screenx.f,screeny.f,stepper.f)
Protected i
Protected s.f
Protected x0,y0
Protected x.f,y.f
s.f=start
i=0
Repeat
y.f=Sin(s*frequenz)*amplitude*screeny+shifty
x.f=i*screenx+shiftx
If i
LineXY(x0,y0,x,y,col)
EndIf
x0=x
y0=y
s+stepper
i+5+Random(5)
Until i>#count
EndProcedure
CreateImage(0,#X*2,#Y*2,32,#White)
StartDrawing(ImageOutput(0))
For wave=0 To 2
frequenz.f=0.6+Random(10)/50+wave*0.01
amplitude.f=18+Random(10)/200+wave*2
start.f=Random(30)
len.f=80+Random(20)
shiftx.f=400+wave*40+xRandom(80)
shifty.f=300+wave*50+xRandom(100)
stepper.f=(len-start)/#count
screenx.f=#x*6/5/#count
screeny.f=#y/100
DrawingMode(#PB_2DDrawing_AlphaBlend)
Select wave
Case 0
col=$1E67DF
Case 1
col=$DF621E
Case 2
col=$1EDF76
EndSelect
d1.f=(xRandom(100))/10000
d2.f=(xRandom(100))/10000
d3.f=(xRandom(100))/400000
d4.f=xRandom(10)/10;
d5.f=xRandom(10)/50;
For i=0 To 1000
start+d1;+(Random(50))/50-1
amplitude+d2;+(Random(50))/500-0.1
frequenz+d3;+(Random(50))/50000-0.001
shiftx+d4+Random(40)/10-2
shifty+d5+Random(10)/10-0.5
z=500-Abs(500-i)
Select z
Case 490 To 500
z>>3
Case 480 To 490
z>>4
Case 400 To 480
z/28
Default
z>>5
EndSelect
showwave(z<<24|col,start,frequenz,amplitude,shiftx,shifty,screenx,screeny,stepper)
Next i
Next wave
ResizeImage(0,#X,#Y)
StopDrawing()
OpenWindow(0,0,0,#X,#Y,"")
ImageGadget(0,0,0,#X,#Y,ImageID(0))
Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow