我目前正在玩弄噪音,比如 Perlin 和 SimplexNoise。当我将 Noise 函数集成到我的代码中时,我得到了一些看起来像静态的东西,这显然不应该是静态的。
这是我当前的代码:
// Width and Height are screen width and height
// Pixelsize is 4
for (int x = 0; x < (width/pixelSize); x++) {
for (int y = 0; y < (height/pixelSize); y++) {
double newColor = SimplexNoise.noise(x, y);
if (newColor > 0) {
g.setColor(Color.black);
} else {
g.setColor(Color.WHITE);
}
g.fillRect(x*pixelSize, y*pixelSize, pixelSize, pixelSize);
}
}
我使用的噪声来自这里:https ://github.com/SRombauts/SimplexNoise/blob/master/references/SimplexNoise.java