fast_noise 0.1.2+2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 68

fast_noise

Fast noise is a direct port from the implementations by Jordan Peck. The Dart version currently does not yet leverage SIMD for better performance.

Usage

fast_noise offers both 2D and 3D noise generation with noise2 and noise3

The following noise types are available:

Demo

Try out some settings here

Examples

Cellular Noise

import 'package:fast_noise/fast_noise.dart';

main() {
  var arr2d = noise2(w, h,
      noiseType: NoiseType.Cellular,
      octaves: 5,
      frequency: 0.015,
      cellularReturnType: CellularReturnType.Distance2Add);
}

Cellular Noise

import 'package:fast_noise/fast_noise.dart';

main() {
  var arr2d = noise2(w, h,
      noiseType: NoiseType.Perlin,
      octaves: 3,
      frequency: 0.05);
      

Perlin Noise

import 'package:fast_noise/fast_noise.dart';

main() {
  var arr2d = noise2(w, h,
      noiseType: NoiseType.SimplexFractal,
      octaves: 4,
      frequency: 0.0075)
      

Simplex Fractal Noise

You can also call a noise type directly:

  var noise = new ValueNoise(interp: Interp.Quintic, octaves: 5);
  // generate 512x512  
  for (int x = 0; x < 512; x++) {
    for (int y = 0; y < 512; y++) {
      noise.singleValueFractalBillow2(x.toDouble(), y.toDouble());
    }
  }

Features and bugs

Please file feature requests and bugs at the issue tracker.

Changelog

0.1.0

  • Initial version

example/example.dart

import 'dart:html';

import 'package:fast_noise/fast_noise.dart';

void main() {
  const w = 512, h = 512;
  final canvas = new CanvasElement(width: w, height: h);
  final map = _getCellular(w, h);
  final context = canvas.getContext('2d') as CanvasRenderingContext2D;
  final imageData = context.createImageData(w, h);

  context.imageSmoothingEnabled = false;

  for (int x = 0; x < w; x++) {
    for (int y = 0; y < h; y++) {
      var s = 4 * (y * h + x);
      var value = (128 + 128 * map[x][y]).floor();

      imageData.data[s] = imageData.data[s + 1] = imageData.data[s + 2] = value;
      imageData.data[s + 3] = 255;
    }
  }

  context.putImageData(imageData, 0, 0, 0, 0, w, h);

  document.body.append(canvas);
}

List<List<double>> _getCellular(int w, int h) => noise2(w, h,
    noiseType: NoiseType.Cellular,
    octaves: 5,
    frequency: 0.015,
    cellularDistanceFunction: CellularDistanceFunction.Euclidean,
    cellularReturnType: CellularReturnType.Distance2Add);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  fast_noise: "^0.1.2+2"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:fast_noise/fast_noise.dart';
  
Version Uploaded Documentation Archive
0.1.2+2 Apr 13, 2018 Go to the documentation of fast_noise 0.1.2+2 Download fast_noise 0.1.2+2 archive
0.1.2+1 Apr 13, 2018 Go to the documentation of fast_noise 0.1.2+1 Download fast_noise 0.1.2+1 archive
0.1.2 Apr 13, 2018 Go to the documentation of fast_noise 0.1.2 Download fast_noise 0.1.2 archive
0.1.1+4 Apr 13, 2018 Go to the documentation of fast_noise 0.1.1+4 Download fast_noise 0.1.1+4 archive
0.1.1+3 Apr 13, 2018 Go to the documentation of fast_noise 0.1.1+3 Download fast_noise 0.1.1+3 archive
0.1.1+2 Apr 13, 2018 Go to the documentation of fast_noise 0.1.1+2 Download fast_noise 0.1.1+2 archive
0.1.1+1 Apr 13, 2018 Go to the documentation of fast_noise 0.1.1+1 Download fast_noise 0.1.1+1 archive
0.1.1 Apr 13, 2018 Go to the documentation of fast_noise 0.1.1 Download fast_noise 0.1.1 archive

Analysis

We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
36 / 100
Health:
Code health derived from static analysis. [more]
100 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
68
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:fast_noise/fast_noise.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
fixnum ^0.10.0 0.10.7
Dev dependencies
benchmark_harness ^1.0.0
test ^0.12.0