CacheProvider constructor

CacheProvider({
  1. required int width,
  2. required int height,
  3. required NoisePlane generator,
  4. CacheCoordinatePlane coordinatePlane = CacheCoordinatePlane.normal,
  5. bool lazy = false,
  6. double? initialValue,
})

Implementation

CacheProvider({
  required int width,
  required int height,
  required NoisePlane generator,
  CacheCoordinatePlane coordinatePlane = CacheCoordinatePlane.normal,
  bool lazy = false,
  double? initialValue,
}) {
  cache = DoubleArrayCacheProvider(
      width: width,
      height: height,
      provider: this,
      initialValue: initialValue,
      coordinatePlane: coordinatePlane);
  if (!lazy) {
    for (int x = 0; x < width; x++) {
      for (int y = 0; y < height; y++) {
        cache.set(x, y, generator.noise2(x.toDouble(), y.toDouble()));
      }
    }
  }
}