fast_noise 0.1.3+1 copy "fast_noise: ^0.1.3+1" to clipboard
fast_noise: ^0.1.3+1 copied to clipboard

outdated

A port of the fast noise algorithms, featuring cellular_noise, cubic_noise, perlin_noise, simplex_noise, value_noise and white_noise

example/example.dart

import 'dart:html';

import 'package:fast_noise/fast_noise.dart';

void main() {
  const w = 512, h = 512;
  final canvas = 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 (var x = 0; x < w; x++) {
    for (var 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);
35
likes
35
pub points
85%
popularity

Publisher

verified publisherblue-fire.xyz

A port of the fast noise algorithms, featuring cellular_noise, cubic_noise, perlin_noise, simplex_noise, value_noise and white_noise

Repository (GitHub)
View/report issues

License

Apache-2.0 (license)

Dependencies

fixnum

More

Packages that depend on fast_noise