New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fractal-noise

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fractal-noise - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

images/cylinder-low-2.png

15

CHANGELOG.md
# Change Log
## Unreleased
## [Unreleased]
### Changed
- Constrain noise source more accurately for `generateCylinder`.
### Fixed
- Use correct operator for 3D noise `y0` calculation.
### Removed
- Remove white noise scaling using `frequency` (makes no difference).
## [v0.1] – 2017-02-14
### Added
- Create functions `generateCylinder`, `generateLine`, `generateRectangle`.
[Unreleased]: https://github.com/joshforisha/fractal-noise-js/compare/v0.1...HEAD
[v0.1]: https://github.com/joshforisha/fractal-noise-js/releases/tag/v0.1

13

lib/index.js

@@ -41,3 +41,3 @@ "use strict";

var _c = [x - _x, y - _y, z - _z], xi = _c[0], yi = _c[1], zi = _c[2];
var _d = [((_x - 1) + sx) % sx, ((_y - 1) + sy) & sy, ((_z - 1) + sz) % sz], x0 = _d[0], y0 = _d[1], z0 = _d[2];
var _d = [((_x - 1) + sx) % sx, ((_y - 1) + sy) % sy, ((_z - 1) + sz) % sz], x0 = _d[0], y0 = _d[1], z0 = _d[2];
var _e = [_x % sx, _y % sy, _z % sz], x1 = _e[0], y1 = _e[1], z1 = _e[2];

@@ -58,6 +58,6 @@ var _f = [(_x + 1) % sx, (_y + 1) % sy, (_z + 1) % sz], x2 = _f[0], y2 = _f[1], z2 = _f[2];

var _a = processOptions(options), amplitude = _a.amplitude, frequency = _a.frequency, octaves = _a.octaves, persistence = _a.persistence;
var size = Math.ceil(Math.max(circumference, height) * frequency);
var white = generateArray(size, function () {
return generateArray(size, function () {
return window.crypto.getRandomValues(new Uint8Array(size));
var diameter = Math.ceil(circumference / Math.PI);
var white = generateArray(diameter, function () {
return generateArray(height, function () {
return window.crypto.getRandomValues(new Uint8Array(diameter));
});

@@ -97,4 +97,3 @@ });

var _a = processOptions(options), amplitude = _a.amplitude, frequency = _a.frequency, octaves = _a.octaves, persistence = _a.persistence;
var size = Math.ceil(Math.max(width, height) * frequency);
var white = generateArray(size, function () { return window.crypto.getRandomValues(new Uint8Array(size)); });
var white = generateArray(width, function () { return window.crypto.getRandomValues(new Uint8Array(height)); });
var noise = generate2DNoiseFn(white);

@@ -101,0 +100,0 @@ return generateArray(width, function (x) { return generateArray(height, function (y) {

{
"name": "fractal-noise",
"version": "0.1.0",
"version": "0.2.0",
"description": "Fractal noise library",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -12,2 +12,34 @@ # Fractal Noise

## Examples
```javascript
generateCylinder(width, height, { frequency: 0.04, octaves: 2 })
```
![Low frequency, double octave cylinder](https://github.com/joshforisha/fractal-noise-js/blob/master/images/cylinder-low-2.png)
```javascript
generateCylinder(width, height, { frequency: 0.06, octaves: 8 })
```
![Medium frequency, high octave cylinder](https://github.com/joshforisha/fractal-noise-js/blob/master/images/cylinder-medium-8.png)
```javascript
generateLine(width) // (Replicated across y-axis)
```
![Default line](https://github.com/joshforisha/fractal-noise-js/blob/master/images/line-default.png)
```javascript
generateLine(width, { frequency: 0.1 }) // (Replicated across x-axis)
```
![High frequency line](https://github.com/joshforisha/fractal-noise-js/blob/master/images/line-high.png)
```javascript
generateRectangle(width, height)
```
![Default rectangle](https://github.com/joshforisha/fractal-noise-js/blob/master/images/rectangle-default.png)
```javascript
generateRectangle(width, height, { frequency: 0.04, octaves: 8 })
```
![Low frequency, high octave rectangle](https://github.com/joshforisha/fractal-noise-js/blob/master/images/rectangle-low-8.png)
## API

@@ -14,0 +46,0 @@

@@ -59,3 +59,3 @@ const TWO_PI = 2 * Math.PI

const [xi, yi, zi] = [x - _x, y - _y, z - _z]
const [x0, y0, z0] = [((_x - 1) + sx) % sx, ((_y - 1) + sy) & sy, ((_z - 1) + sz) % sz]
const [x0, y0, z0] = [((_x - 1) + sx) % sx, ((_y - 1) + sy) % sy, ((_z - 1) + sz) % sz]
const [x1, y1, z1] = [_x % sx, _y % sy, _z % sz]

@@ -106,6 +106,6 @@ const [x2, y2, z2] = [(_x + 1) % sx, (_y + 1) % sy, (_z + 1) % sz]

const { amplitude, frequency, octaves, persistence } = processOptions(options)
const size = Math.ceil(Math.max(circumference, height) * frequency)
const white = generateArray(size, () =>
generateArray(size, () =>
window.crypto.getRandomValues(new Uint8Array(size))
const diameter = Math.ceil(circumference / Math.PI)
const white = generateArray(diameter, () =>
generateArray(height, () =>
window.crypto.getRandomValues(new Uint8Array(diameter))
)

@@ -143,4 +143,3 @@ )

const { amplitude, frequency, octaves, persistence } = processOptions(options)
const size = Math.ceil(Math.max(width, height) * frequency)
const white = generateArray(size, () => window.crypto.getRandomValues(new Uint8Array(size)))
const white = generateArray(width, () => window.crypto.getRandomValues(new Uint8Array(height)))
const noise = generate2DNoiseFn(white)

@@ -147,0 +146,0 @@ return generateArray(width, x => generateArray(height, y =>

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc