Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. local high = 8
  2.  
  3. if !c then
  4.    noise = {}
  5.    for x=0,2^high+1 do
  6.       noise[x] = {}
  7.       for y=0,2^high+1 do
  8.          noise[x][y] = math.random()
  9.       end
  10.    end
  11.    c = true
  12. end
  13.  
  14. local N = 0
  15. for i=1,high do
  16.    local freq = 2^i
  17.    local X = freq*x/ScrW()
  18.    local X_i = math.floor(X)
  19.    local X_f = X-X_i
  20.    local Y = freq*y/ScrH()
  21.    local Y_i = math.floor(Y)
  22.    local Y_f = Y-Y_i
  23.    
  24.    local n0 = noise[X_i][Y_i]*(1-X_f)+noise[X_i+1][Y_i]*X_f
  25.    local n1 = noise[X_i][Y_i+1]*(1-X_f)+noise[X_i+1][Y_i+1]*X_f
  26.    
  27.    N = N+n0*(1-Y_f)+n1*Y_f
  28. end
  29.  
  30. N = N/high
  31.  
  32. local d = math.sqrt((x/ScrW()-0.5)^2+(y/ScrH()-0.5)^2)
  33.  
  34. N = math.pow(1-N*d,1.2)
  35.  
  36. surface.SetDrawColor(N*255,255*N^2,255*N^3)
  37. surface.DrawRect(x,y,1,1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement