open_simplex_2 0.2.0+1
open_simplex_2: ^0.2.0+1 copied to clipboard

Dart implementation of KdotJPG's OpenSimplex2 noise algorithms.

open_simplex_2 Pub version GitHub stars Twitter Follow #

Dart implementation of KdotJPG's OpenSimplex2 noise algorithms.

Getting started #

To use this plugin, follow the installing guide.

Usage #

The package currently offers two OpenSimplex 2 noise implementations:

Both of them are used in the same way. You initialize an instance with a seed:

final noise = OpenSimplex2F(42);

This instance now allows you to evaluate noise. Here are some example calls:

noise.noise2(x, y);
noise.noise3Classic(x, y, z);
noise.noise3XYBeforeZ(x, y, z);
noise.noise4Classic(x, y, z, w);
noise.noise4XYBeforeZW(x, y, z, w);

Common interface #

Both OpenSimplex2F and OpenSimplex2S share the same public interface. This is defined as OpenSimplex2.

This is useful e.g. when you want to toggle between the smoother and faster variant:

late OpenSimplex2 noise;

void initNoise({required bool faster}) {
  if (faster) {
    noise = OpenSimplex2F(42);
  } else {
    noise = OpenSimplex2S(42);
  }
}

Motivation #

I ported the library to Dart in order to use it in my funvas animations.

If you are interested, you can view the gallery, follow on Twitter (where I regularly post animations), or view some of the example integrations I wrote :)

Here are some examples to start:

Background #

To understand how the noise in OpenSimplex 2 works, see KdotJPG's Reddit post.

Implementation #

The current implementation is based on the Java implementation in KdotJPG/OpenSimplex2.

I see two potential ways to improve on it:

  • Port the areagen code from the main repo.
  • Use the newer, faster implementations by K.jpg that have not yet been merged into the main repo.
7
likes
130
pub points
35%
popularity

Publisher

creativemaybeno.dev

Dart implementation of KdotJPG's OpenSimplex2 noise algorithms.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

fixnum

More

Packages that depend on open_simplex_2