elaborated on mike's code to produce some kind of noise explorer:
SetWindowSize(512,512,0)
SetVirtualResolution(512,512)
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
SetPrintSize(36)
FreTXT = AddTXT(0,0)
AmpTXT = AddTXT(256,0)
LacTXT = AddTXT(0,48)
PerTXT = AddTXT(256,48)
#CONSTANT MWD = GetRawMouseWheelDelta()
#CONSTANT MX = GetPointerX()
#CONSTANT MY = GetPointerY()
Do
If Flag = 0
Frequency# = random ( 1, 100 ) / 1000.0
Amplitude# = random ( 1, 100 ) / 100.0
Lacunarity# = random ( 1, 5 )
Persistence# = 1.0 / 2.0
EndIf
Flag = 0
SetupNoise ( Frequency#, Amplitude# , Lacunarity# , Persistence# )
data as integer [ 196608 ]
fr as float
f as float
k = 1
fr = random ( 1, 10 )
for x = 1 to 256
for y = 1 to 256
f = GetFractalXY ( fr, x, y )
f = AdjustValue ( f, -1, 1, 0, 255 )
data [ k ] = f
k = k + 1
f = GetFractalXY ( fr, x, y )
f = AdjustValue ( f, -1, 1, 0, 255 )
data [ k ] = f
k = k + 1
f = GetFractalXY ( fr, x, y )
f = AdjustValue ( f, -1, 1, 0, 255 )
data [ k ] = f
k = k + 1
next y
next x
a = img_create_RGBA ( 256, 256, data )
b = CreateSprite ( a )
SetSpritePosition(b,128,128)
SetTextString(FreTXT,"F: " + STR(Frequency#))
SetTextString(AmpTXT,"A: " + STR(Amplitude#))
SetTextString(LacTXT,"L: " + STR(Lacunarity#))
SetTextString(PerTXT,"P: " + STR(Persistence#))
Repeat
If GetRawKeyState(27) then End
If MWD <> 0.0
If MWD < 0 then This# = -1.0 else This# = 1.0
If GetTextHitTest(FreTXT, MX,MY)
INC Frequency#, This#*0.001 : Flag = 1
EndIf
If GetTextHitTest(AmpTXT, MX,MY)
INC Amplitude#, This#*0.25 : Flag = 1
EndIf
If GetTextHitTest(LacTXT, MX,MY)
INC Lacunarity#, This#*0.1 : Flag = 1
EndIf
If GetTextHitTest(PerTXT, MX,MY)
INC Persistence#, This#*0.1: Flag = 1
EndIf
EndIf
sync ( )
Until Flag = 1 or GetPointerReleased()
count = count + 1
DeleteSprite ( b )
DeleteImage ( a )
sync ( )
Loop
function AdjustValue ( value as float, minFrom as float, maxFrom as float, minTo as float, maxTo as float )
ret as float
ret = minTo + ( maxTo - minTo ) * ( ( value - minFrom ) / ( maxFrom - minFrom ) )
endfunction ret
function img_create_RGBA(www,hhh, data as integer[])
//creates an image of 'www' by 'hhh' pixels with defined color
size = 12 +www *hhh *4 // memblock //'size' is summary of image width (integer, 4 bytes),
//image height (integer, 4 bytes), image depth (integer, 4 bytes) - that
//is 12 bytes - and raw image data (the number of pixels multiplied by 4
// bytes)
mmm = createMemblock(size)
setMemblockInt(mmm, 0, www) //writing starts with offset 0
setMemblockInt(mmm, 4, hhh) //variable 'www' occupies 4 bytes, so now offset 0 +4 = 4
setMemblockInt(mmm, 8, 32) //variable 'hhh' occupies 4 bytes, so now offset 4 +4 = 8
dec size //since writing starts with offset 0, it ends at one stage earlier than the memblock
// 'size'
k = 1
for nnn = 12 to size
setMemblockByte(mmm, nnn, data[k])
k = k + 1
inc nnn
setMemblockByte(mmm, nnn, data[k])
k = k + 1
inc nnn
setMemblockByte(mmm, nnn, data[k])
k = k + 1
inc nnn
setMemblockByte(mmm, nnn, 255)
next nnn
nnn = createImageFromMemblock(mmm)
deleteMemblock(mmm)
endfunction nnn
Function AddTXT(x,y)
ThisTXT = CreateText("")
SetTextSize(ThisTXT,36)
SetTextAlignment(ThisTXT,0)
SetTextPosition(ThisTXT,x,y)
Endfunction ThisTXT
use the mousewheel while hovering over a parameter to increase/decrease value, or click anywhere to randomize.
still learning helpful ranges for each, proper increments, and how they might work/(together). the
repo for OpenSimplex doesn't give much insight, nor do other repos working with it that i've reviewed.
i've set the INC values to what i THINK make sense for each; let us know if you find lay-person sense of it all?
BTW, the FRACTAL stuff sounds delicious. any usage guidance, there? new toys are frustrating if you don't know how to play with them