
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
script tags. Module uses ES6 promises. This module has ZER0 dependencies whatsoever.Deliver the package via cdn:
https://cdn.jsdelivr.net/npm/worleyjs
https://unpkg.com/worleyjs
To install with NPM run:
npm install worleyjs
Include the file worley.min.js in your project directory. Then:
Browser:
<script src="path/to/worley.min.js">
Node:
const Worley = require("worleyjs");
In the build directory is an es6 module implementation of the library. The main|default import of the module id the Worley class itself:
import Worley from "worley.min.mjs";
requirejs(["path/to/worley.min.mjs"], function(Worley) {
// Do yo stuff over here
});
To validate installation. Run:
npm run test
The module exposes a Worley class. The Worley instance contains all the methods and properties needed for the generation of Worley noise.
The crests property defines how many "spots" there are in the texture.
The threshold argument dictates how far the slope of a crest extends. It is optional and when not passed a value is calculated using the width, height and crests values.
The seed argument is an array of 4 numbers which are seed to the RNG of the Texture.
let noise = new Worley({
width: 512, // In pixels
height: 512, // In pixels
threshold: 258,
crests: 15,
seed: [12345, 45678, 67890, 12345]
});
// Full texture access
noise.Texture.ImageData().then((imgData) => {
// Do something like ctx.putImageData(imgData)
console.log(imgData); // {width: Number ,height: Number ,data: Uint8Array => [0,1,2....n]
})

Colour: To add colour to the texture simply pass a colorparameter with an array containing colour data for the first and second colour.
// RGB
{ colors: [[94, 6, 0], [230, 176, 20]] }
Transparency: To include the transparency to your texture. For more detailed transparency, pass a number to the alpha property where 0 is for no alpha influence and 1 is for full alpha influence. A number above 1 will overshoot the alpha and a value of 255 turns the texture fully transparent.
// Transparency
{ alpha: true}
Interpolation: You can "turn off" interpolation for a little (mostly insignificant) speed boost. This doesn't actually turn off interpolation but rather uses bilinear interpolation ( simple distance from a point ) to calculate values. 😁. It also disables custom interpolation functions.
// Toggle interpolation
{ interpolate: false }
Custom Interpolation Functions: To pass a custom interpolation function, simply pass a compatible function to the interpolant property in the config object of the noise instance. The interpolate property needs to be set to true for this to work. The interpolant function takes three numbers. A lower value, an upper value and a slider value( which ranges from 1 to 0 ). With this function crazy effects can be achieved like belts, spots and cat fur patterns. Expected behaviour is that the slider defines a point on an interpolation curve, thus the closer the slider is to 0 the closer it is to the lower end of the graph, what the function does is simply define the shape of the curve. This is expected behaviour, you can obviously do whatever you want in the interpolant value, as long as it abides to the following rules:
{
interpolant: function(lower, upper, slider){
// Simple cut-off interpolant
if( slider >= 0.2 ){
return upper
} else {
return lower
}
}
}

Toggle various distance metrics: Manhattan, Euclidean and Minkowski distance metrics are supported.
// Euclidean
{ metric: {type: "euclidean"} };
// Manhattan
{ metric: {type: "manhattan"} };
// Minkowski takes a second parameter, p: Number
{ metric: {type: "minkowski", p: 2} };
Manually add a crest: To add a crest manually to a point in the texture, use relative coordinates from 0 - 1:
// This adds a spot|crest to the centre of the texture using relative co-ordinates.
noise.addCrest(0.5, 0.5);
// To add a point using absolute co-ordinates.
noise.addCrest(120, 100, false);
Value Of A Given Pixel: To get the value of a single pixel. Given the x and y co-ordinates.
// noise.pixel(x: in pixels, y: in pixels, ?interpolate, ?hierachy: which crest to consider first)
// returns a promise which resolves to a number between 0 and 255
noise.pixel(50, 50, true, 2).then((value) => {
// Do something
console.log(value);
})
Raw Data: To access the raw noise values and not the RGBA texture.
// Raw single channel noise data. Stored as an Uint8Array ( a typed array of Unsigned 8-bit integers ).
noise.Texture.generate().then((raw) => {
// Do something with the data
console.log(raw);// Uint8Array[100,24, 53,24....n]
})
Nearby Crest: If you want to find the closest "crest" given a set of co-ordinates.
// X, Y, ?hierachy
noise.nearestCrest(x, y, 0).then((crest) => {
// Outputs an array containing 2d co-ordinates in pixels
console.log(crest); // -> [45, 56]
})
git clone https://github.com/sokorototo/worleyjs.git
cd worleyjs
npm install
npm run build
worley.min.**jsfiles in the build folder.
FAQs
An embedabble and simple Worley Noise generator written in Javascript
We found that worleyjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.