Available since LÖVE 0.9.0
This function is not supported in earlier versions.
Generates a Simplex or Perlin noise value in 1-4 dimensions. The return value will always be the same, given the same arguments.
Simplex noise is closely related to Perlin noise. It is widely used for procedural content generation.
There are many webpages which discuss Perlin and Simplex noise in detail.
The return value might be constant if only integer arguments are used. Avoid solely passing in integers, to get varying return values.
Generates Simplex noise from 1 dimension.
value = love.math.noise( x )
number xnumber valueGenerates Simplex noise from 2 dimensions.
value = love.math.noise( x, y )
number xnumber ynumber valueGenerates Perlin noise (Simplex noise in version 0.9.2 and older) from 3 dimensions.
value = love.math.noise( x, y, z )
number xnumber ynumber znumber valueGenerates Perlin noise (Simplex noise in version 0.9.2 and older) from 4 dimensions.
value = love.math.noise( x, y, z, w )
number xnumber ynumber znumber wnumber valueFills a two-dimensional grid with simplex noise each time a key is pressed.
local grid = {}
function love.draw()
for x = 1, #grid do
for y = 1, #grid[x] do
local f = 1 * grid[x][y]
love.graphics.setColor( f, f, f, 1 )
love.graphics.rectangle( 'fill', x * 8, y * 8, 7, 7 )
love.graphics.setColor( 1, 1, 1, 1 )
end
end
end
-- Fill each pixel in our grid with simplex noise.
local function noise()
for x = 1, 60 do
for y = 1, 60 do
grid[x] = grid[x] or {}
grid[x][y] = love.math.noise( x + love.math.random(), y + love.math.random() )
end
end
end
function love.keypressed()
noise()
end
© 2006–2020 LÖVE Development Team
Licensed under the GNU Free Documentation License, Version 1.3.
https://love2d.org/wiki/love.math.noise