fast_noise 0.1.2+3

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

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+3

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+3 Feb 26, 2019 Go to the documentation of fast_noise 0.1.2+3 Download fast_noise 0.1.2+3 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
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
76
Learn more about scoring.

We analyzed this package on Apr 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

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

Health issues and suggestions

Document public APIs. (-0.83 points)

175 out of 176 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <3.0.0
fixnum ^0.10.0 0.10.9
Dev dependencies
benchmark_harness ^1.0.0
build_runner ^0.9.2
build_web_compilers ^0.4.1
test ^1.3.0