Comments (6)
This looks very promising, thank you for making this!
from open-simplex-noise-js.
https://stackblitz.com/edit/open-simplex-noise-example?file=index.js
(noise3D(x / 50, y / 50, 0) + 1) * 128;
I found passing x y as non-integer, will result in a good image. Why? Shouldn't it be int?
from open-simplex-noise-js.
So the example should be
import { makeNoise3D } from "open-simplex-noise";
const [width, height] = [300, 300];
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
const imageData = ctx.createImageData(width, height);
const noise3D = makeNoise3D(2);
for (let x = 0; x < width; x++) {
for (let y = 0; y < height; y++) {
const i = (x + y * width) * 4;
const value = (noise3D(x / 50, y / 50, 0) + 1) * 128;
imageData.data[i] = value;
imageData.data[i + 1] = value;
imageData.data[i + 2] = value;
imageData.data[i + 3] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
from open-simplex-noise-js.
Hi, thanks for the issue. Yes, it's true that this type of noise generation is often used for things like landscape generation, as well as many other applications. What you're describing in this issue and #8 is an application more about fractal noise, which involves scaling (what you're doing with x / 50
and y / 50
) and adding layers together with various parameters to get different results.
I've authored another library, joshforisha/fractal-noise-js (NPM: fractal-noise), focused on supplying fractal functions for that type of application. It's intended to be used independently of any specific underlying noise generation algorithm, however, hence the separation of this library from that.
Having said all that, I think you're right about providing an example for this application—or at least details I've mentioned here—so I'll be expanding the README soon.
from open-simplex-noise-js.
Wow, that looks exactly what I want. I didn't know about this, I thought that effect on the right can only get from Perlin noise.
Seems you can get that from simple ValueNoise...
So I can use it like this?
import { makeNoise3D } from "open-simplex-noise";
makeCylinderSurface(width, height, makeNoise3D, { frequency: 0.04, octaves: 2 })
from open-simplex-noise-js.
Got it, use it like https://stackblitz.com/edit/open-simplex-noise-example-fractal?file=index.js
import { makeNoise3D } from "open-simplex-noise";
import { makeCylinderSurface } from "fractal-noise";
const [width, height] = [300, 300];
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");
const imageData = ctx.createImageData(width, height);
const noise3D = makeNoise3D(0);
const data = makeCylinderSurface(width, height, noise3D, { frequency: 0.04, octaves: 2 })
for (let x = 0; x < width; x++) {
for (let y = 0; y < height; y++) {
const i = (x + y * width) * 4;
const value = (data[x][y] + 0.5) * 128;
imageData.data[i] = value;
imageData.data[i + 1] = value;
imageData.data[i + 2] = value;
imageData.data[i + 3] = 255;
}
}
ctx.putImageData(imageData, 0, 0);
from open-simplex-noise-js.
Related Issues (7)
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 open-simplex-noise-js.