Comments (8)
Sorry, I'm not sure I understand what you're trying to do.
On Friday, 26 February 2016, Andrew Mast [email protected] wrote:
How do I make the seed work for 2^32 or 2^64 numbers?
—
Reply to this email directly or view it on GitHub
#15.
from noisejs.
How do I change this function to work for 2^32 or 2^64 numbers?
// This isn't a very good seeding function, but it works ok. It supports 2^16
// different seed values. Write something better if you need more seeds.
module.seed = function(seed) {
if(seed > 0 && seed < 1) {
// Scale the seed out
seed *= 65536;
}
seed = Math.floor(seed);
if(seed < 256) {
seed |= seed << 8;
}
for(var i = 0; i < 256; i++) {
var v;
if (i & 1) {
v = p[i] ^ (seed & 255);
} else {
v = p[i] ^ ((seed>>8) & 255);
}
perm[i] = perm[i + 256] = v;
gradP[i] = gradP[i + 256] = grad3[v % 12];
}
};
from noisejs.
Why do you want that? Do you simply want more variety in the output?
from noisejs.
I want to be able use this:
String.prototype.hashCode = function() {
var hash = 0, i, chr, len;
if (this.length === 0) return hash;
for (i = 0, len = this.length; i < len; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
from noisejs.
So basically I want to know what to do with the module.seed
to make it work with 2^32 numbers (So I can use noise.seed("seed".hashCode());
)
from noisejs.
You can take your 2^32 number and divide it by 2^32 then use that.
from noisejs.
With this?
String.prototype.hashCode = function() {
var hash = 0, i, chr, len;
if (this.length === 0) return hash;
for (i = 0, len = this.length; i < len; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash / Math.pow(2, 32);
};
from noisejs.
This should work yes.
from noisejs.
Related Issues (20)
- seed should not be global HOT 3
- How to increase octaves? HOT 1
- Why do integer values for x and y always return 0 for noise.perlin? HOT 3
- GLSL equivalent solution to simplex3? HOT 1
- Simplex2 results identical regardless of seed provided.
- n dimensions HOT 1
- perlin2 only returns 0? HOT 1
- License confusin, the files says ICS but the file inside says public domain? HOT 3
- Why does the demo have sharp steps in the color? HOT 1
- FYI: 'Pretty' Demo Is a Dead Link HOT 3
- Uncaught TypeError: Cannot set property 'noise' of undefined HOT 2
- Is there a octaves function by any chance? HOT 2
- 1D noise? HOT 3
- 4D noise? HOT 1
- Uncaught TypeError: Cannot set property 'Noise' of undefined HOT 1
- you realize we cant view the demo, right? HOT 7
- Trouble importing HOT 3
- use requirejs and commonjs wrapper HOT 1
- add to bower and npm HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from noisejs.