redef fun [](x, y)
do
x = x/period
y = y/period
# Get grid coordinates
var x0 = if x > 0.0 then x.to_i else x.to_i - 1
var x1 = x0 + 1
var y0 = if y > 0.0 then y.to_i else y.to_i - 1
var y1 = y0 + 1
# Position in grid
var sx = x - x0.to_f
var sy = y - y0.to_f
# Interpolate
var n0 = gradient_dot_product(x0, y0, x, y)
var n1 = gradient_dot_product(x1, y0, x, y)
var ix0 = sx.lerp(n0, n1)
n0 = gradient_dot_product(x0, y1, x, y)
n1 = gradient_dot_product(x1, y1, x, y)
var ix1 = sx.lerp(n0, n1)
var val = sy.lerp(ix0, ix1)
# Return value in [min...max] from val in [-1.0...1.0]
val /= 2.0
val += 0.5
return val.lerp(min, max)
end
lib/noise/noise.nit:280,2--308,4