noise 0.5.1 copy "noise: ^0.5.1" to clipboard
noise: ^0.5.1 copied to clipboard

Dart 1 only

Noise algorithms.

example/noise_example.dart

library noise_example;

import 'dart:html';
import 'package:noise/noise.dart';

void main() {
  var canvas = document.querySelector("#canvas");
  var ctx = canvas.getContext('2d');
  
  var img = ctx.createImageData(canvas.width, canvas.height);
  var octave = makeOctave2(simplex2, 3, 0.5);
  
  for (var y = 0; y < canvas.height; y++) {
    for (var x = 0; x < canvas.width; x++) {
      //var noise = simplex2(x/50, y/50);
      var noise = octave(x/50, y/50);
      int val = ((noise + 1) * 128).round();
      int i = x + y*canvas.width;
      img.data[i*4 + 0] = val;
      img.data[i*4 + 1] = val;
      img.data[i*4 + 2] = val;
      img.data[i*4 + 3] = 255;
    }
  }
  
  ctx.putImageData(img, 0, 0);
}
0
likes
20
pub points
36%
popularity

Publisher

unverified uploader

Noise algorithms.

Repository (GitHub)
View/report issues

License

BSD-2-Clause-Views (license)

More

Packages that depend on noise