## LoveNoise - A Love Noise library [v0.2.1]

substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

### LoveNoise - A Love Noise library [v0.2.1]

Here's another one of my libraries.

LoveNoise!

Repository: https://github.com/icrawler/LoveNoise
Project page and documentation: http://icrawler.github.io/LoveNoise/

[copy of readme.md for version 0.1.5. 0.2.x now has a different codebase]
LoveNoise is a wrapper library for LOVE's noise functions.

Installation

The lovenoise.lua and the presetnoise.lua files should be dropped into an existing project and require lovenoise.

Code: Select all

lovenoise = require "lovenoise"
Examples

Creating a new noise object:

Code: Select all

-- This creates a new Noise object called testNoise which contains two noise
-- functions.
testNoise = lovenoise.newNoise(
{"fractal", 64, {3, 0.5, 2}},
{"simplex", 128}
)
-- The following lines sets testNoise's threshold and seed to 0.2 and 1337
-- respectively.
testNoise:setthreshold(0.2)
testNoise:setseed(1337)

-- The previous lines can also be done in this way:
testNoise:setthreshold(0.2):setseed(1337)

Using the new noise object:

Code: Select all

-- This returns the value of the multiplied noise function values at position
-- x=0.2, y=0.5, thresholded by 0.2 and seeded by 1337.
local val = testNoise:eval(0.2, 0.5)
Noise Format

Code: Select all

	{"nameofnoise", scale, {args, if, any}},
{"othernoise", scale, {args, if, any}},
...

Available Noise Methods

:setthreshold(threshold)
Sets the threshold for the result value. If threshold is less than 0,
thresholding is disabled.

:setseed(seed)
Sets the seed value for the noise object. If the function is called with no
arguments, it's set to the default value.

:setnormalized(normalized)
Changes whether the noise object will return a value from -1 to 1 or not.

:setoperation(operation)
Changes which operation to use when combining noise. Valid operations: multiply, divide, add, subtract.

:setmap(map)
Sets the mapping function to use when evaluating values. If the function is called with no arguments, it's set to nil.

:eval(...)
Evaluates the value of the combined noise functions at a given position (up to 4 dimensions are possible.)

:evaluate(i, pos)
Evaluates the value of the ith noise function at a given position (up to 4 dimensions are possible.)

Available Noise Functions

"fractal"

Generates fractal noise.

Args:
* n (required) - number of octaves
* a (default: 0.5) - amplitude scaling factor
* f (default: 2) - frequency scaling factor

"simplex"

Generates ordinary simplex noise.

No arguments.

"ridged"

Generates ridged multi-fractal noise.

Args:
* n (required) - number of octaves
* a (default: 0.5) - amplitude scaling factor
* f (default: 2) - frequency scaling factor

Util functions

lovenoise.findOctaveLimit(a, d)

Returns the maximum octave limit.

Args:
* a - amplitude scaling factor
* d - amount of detail

Example:

Code: Select all

print(lovenoise.findOctaveLimit(0.5, 255))
>>> 8
Changelog

Code: Select all

0.2.1
-----
* Added billow noise and invert module.

0.2.0
-----
* Rewrote codebase. Now uses Noise Module objects instead of tables.

0.1.5
-----
* changed noise format for convenience.

0.1.4
-----
* Added support for multidimensional noise.

0.1.3
-----

0.1.2
-----

0.1.1
-----

* Added ridged multi-fractal noise (http://libnoise.sourceforge.net/docs/classnoise_1_1module_1_1RidgedMulti.html)

* Divided final value of fractal noise by the maximum value it can attain, to completely remove values going out of bounds

0.1.0
-----

* Initial commit
* Added fractal noise

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Last edited by substitute541 on Mon Jun 23, 2014 6:35 am, edited 9 times in total.
Currently designing themes for WordPress.

Sometimes lurks around the forum.
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.2]

Sounds nice.
Did I missed something, or dit you forgot to share the link to the code ?
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.2]

Roland_Yonaba wrote:Sounds nice.
Did I missed something, or dit you forgot to share the link to the code ?
Oh crap.

Biggest derp I ever had ._.

Here: https://github.com/icrawler/LoveNoise
Currently designing themes for WordPress.

Sometimes lurks around the forum.
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.2]

Roland_Yonaba wrote:Sounds nice.
Herp derp, "sounds" - "Noise"
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping

Lua Hal
Citizen
Posts: 58
Joined: Tue Jul 12, 2011 10:30 pm

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.2]

So can I become the next Merzbow with this? I was actually listening to one of his collabs when I saw this thread
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.2]

Lua Hal wrote:So can I become the next Merzbow with this? I was actually listening to one of his collabs when I saw this thread
This is supposed to be an easy way to create and chain Simplex Noises (and variations) together.

Oh well, but you can feed it into love.sound's modules and stuff if you want. Maybe you'll get some trippy sound effects.
Currently designing themes for WordPress.

Sometimes lurks around the forum.
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.2]

A couple of examples just so this won't sink into the bottom of the Love forums.
Fractal noise with 100 scale, 6 octaves (n), 0.7 persistence (a), 1.4 lacunarity (f)
fractal100s6n0.7a1.4f.png (144.86 KiB) Viewed 3715 times
Ridged Multifractal noise with 130 scale, 7 octaves (n), 0.5 persistence (a), 2 lacunarity (f)
ridged130s7n0.5a2f.png (195.99 KiB) Viewed 3715 times
Ridged Multifractal noise with 130 s, 2 n, 0.5 a, 2 f multiplied by Fractal noise with 100 s, 2 n, 0.5 a, 3 f
ridged130s2n0.5a2f times fractal100s2n0.5a3f.png (85.74 KiB) Viewed 3715 times
Currently designing themes for WordPress.

Sometimes lurks around the forum.
Lua Hal
Citizen
Posts: 58
Joined: Tue Jul 12, 2011 10:30 pm

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.3]

Joking aside, it looks quite good. I'm not sure what I'd use it for, but my projects are uncomplicated and shouldn't really be done in Love anyway.
Mermersk
Party member
Posts: 108
Joined: Tue Dec 20, 2011 3:27 am

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.3]

Hi Substitue,

I am trying to learn Noise with the help of your library! But have hit a problem here and some questions.

1) Why is the code posted below just not working? I get "lovenoise.lua:104: attempt to index local "noise"(a number value). main.lua line 21.
So the problem is in the "val = fyrstaNoise:eval(x, y)" thingy. The code here is nearly identical to this: https://github.com/icrawler/LoveNoise/b ... r/main.lua

"val" is also used in that example, why what does it stand for?

2) Why are there more noise modifiers on the Github page than on this forum post ? Just noticed also that :eval modifier isn't listed here on the forum. What does this modifier do ?

3) If you want to actually see the noise, then it is correct that you always have to put it on "imagedata" first and then convert it to a drawable image? If you don't do that then the only way you could see noise is through movement of other things(other images and so on) ?

4) I think it was you that posted here on the forums earlier a "2d water project" that was done through noise? That is what I will try to make, but I also want to learn about this "noise" so I can have other uses of it too.

Code: Select all

lovenoise = require("lovenoise")

function mapping(val)
return val
end

fyrstaNoise = lovenoise.newNoise({"simplex", 128})
fyrstaNoise:setseed(140)
fyrstaNoise:setmap(mapping)

noisedata = love.image.newImageData(512, 512)
for y = 1, 512 do
for x = 1, 512 do
val = fyrstaNoise:eval(x, y)
noisedata:setPixel(x, y, val*255, val*255, 0, 255)
end
end

noiseimage = love.graphics.newImage(noisedata)

end

function love.update(dt)

end

function love.draw()
--love.graphics.line(fyrstanoise)
--love.graphics.setColor(34, 170, 45)

love.graphics.draw(noiseimage)

end
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

### Re: LoveNoise - A Love Noise Wrapper library [v0.1.3]

Mermersk wrote:Hi Substitue,

I am trying to learn Noise with the help of your library! But have hit a problem here and some questions.

1) Why is the code posted below just not working? I get "lovenoise.lua:104: attempt to index local "noise"(a number value). main.lua line 21.
So the problem is in the "val = fyrstaNoise:eval(x, y)" thingy. The code here is nearly identical to this: https://github.com/icrawler/LoveNoise/b ... r/main.lua

"val" is also used in that example, why what does it stand for?

2) Why are there more noise modifiers on the Github page than on this forum post ? Just noticed also that :eval modifier isn't listed here on the forum. What does this modifier do ?

3) If you want to actually see the noise, then it is correct that you always have to put it on "imagedata" first and then convert it to a drawable image? If you don't do that then the only way you could see noise is through movement of other things(other images and so on) ?

4) I think it was you that posted here on the forums earlier a "2d water project" that was done through noise? That is what I will try to make, but I also want to learn about this "noise" so I can have other uses of it too.

Code: Select all

lovenoise = require("lovenoise")

function mapping(val)
return val
end

fyrstaNoise = lovenoise.newNoise({"simplex", 128})
fyrstaNoise:setseed(140)
fyrstaNoise:setmap(mapping)

noisedata = love.image.newImageData(512, 512)
for y = 1, 512 do
for x = 1, 512 do
val = fyrstaNoise:eval(x, y)
noisedata:setPixel(x, y, val*255, val*255, 0, 255)
end
end

noiseimage = love.graphics.newImage(noisedata)

end

function love.update(dt)

end

function love.draw()
--love.graphics.line(fyrstanoise)
--love.graphics.setColor(34, 170, 45)

love.graphics.draw(noiseimage)

end
1) You forgot to add another set of closing braces to the noise. I'll have to edit the format later in the next version to make it more convenient.

Code: Select all

fyrstaNoise = lovenoise.newNoise({ {"simplex", 128} })

The 'val' variable is a value ranging from 0 to 1. It's the amplitude of the noise in that current location.
2) Rather than modifiers they are called methods now. And I also rarely update my library forum posts unless the library is stable and complete.
3) Yes, if you want to see the noise you have to show it as an image.
4) Yes that was me. And good luck with that
Currently designing themes for WordPress.

Sometimes lurks around the forum.

### Who is online

Users browsing this forum: Google [Bot], Rick Astley and 10 guests