Thank you kryton9 for the noise function, i haven't focused on this subject before, now i find it interesting. but what confuse me is that for any 3 numbers the result is the same as before ie it is not like the RND function. which gives different results , i will read the explanation here about perlin noise http://web.archive.org/web/201602271...s/m_perlin.htm
since he said "If you pass it the same parameter twice, it produces the same number twice. It is very important that it behaves in this way, otherwise the Prelim function will simply produce nonsense"
i have tried your function noise to plot x, y, 0 by plotting the noise output as if it is y. the result is like a chaotic heart pulses
perlin.PNG
if we change yy = yy + 0.03 to yy = yy + 1 it will be more chaotic
using a Canvas_SineCurve.tbasuc as a template:
with your include file "PerlinNoise.tbasici"
Uses "UI"
#INCLUDE "PerlinNoise.tbasici"
'-----------------------------------------------------------
'---Global variables
'-----------------------------------------------------------
Function TBMain () As Long
Dim ScreenWidth As Long = 800
Dim ScreenHeight As Long = 600
Dim hWin As DWord '---Handle of the canvas window
Dim x,y,yy As Double
Dim thick As Double
Long f
'-----------------------------------------------------------
'---Main program
'-----------------------------------------------------------
hWin = Canvas_Window("Perlin Noise: press ESC to exit", 1, 1, ScreenWidth, ScreenHeight)
Canvas_Attach(hWin, 0, %TRUE) ' <- double buffer
'---Init canvas
Canvas_Clear %BLACK
Canvas_Font "Arial" , 8, %CANVAS_FONTSTYLE_NORMAL
'---Set personalized canvas scale
Canvas_Scale(-20, -5, 20, 20)
yy = -15
'---Loop For All steps
For x = -15 To 15 Step 0.02
yy = yy + 0.03
y = PerlinNoise( x, yy, 0 )
thick = 3
Canvas_Width(thick)
Canvas_Line( (x, y*3), (x, y*3) , Rgb(25 * thick, 255, 0) )
f+1
If f=6 Then 'to make the animation faster
Canvas_Redraw
f=0
End If
If GetAsyncKeyState(%VK_ESCAPE) Then Exit For
Next
Do
Loop While All( Asc(Canvas_WaitKey) <> 27, IsWindow(hWin) )
Canvas_Window End
End Function
Bookmarks