noise2 method
Implementation
@override
double noise2(double x, double y) {
int xr = round(x);
int yr = round(y);
double distance = 999999;
int xc = 0, yc = 0, zc = 0;
for (int xi = xr - 1; xi <= xr + 1; xi++) {
for (int yi = yr - 1; yi <= yr + 1; yi++) {
D2 vec = CELL_2D[hash2D(seed, xi, yi) & 255];
double vecX = xi - x + vec.x;
double vecY = yi - y + vec.y;
double newDistance =
(vecX.abs() + vecY.abs()) + (vecX * vecX + vecY * vecY);
if (newDistance < distance) {
distance = newDistance;
xc = xi;
yc = yi;
}
}
}
return valCoord2D(0, xc, yc);
}