Skip to content

Instantly share code, notes, and snippets.

@Limeth
Created February 6, 2017 10:40
Show Gist options
  • Save Limeth/35d519df9c1e6fc8c4731fc05ccf5937 to your computer and use it in GitHub Desktop.
Save Limeth/35d519df9c1e6fc8c4731fc05ccf5937 to your computer and use it in GitHub Desktop.
public static final int WIDTH = 128;
public static final int HEIGHT = WIDTH;
public static final double PERIOD = 1000;
public static void main(String[] args) throws IOException {
Perlin perlin = new Perlin();
Path path = Paths.get("perlin.png");
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = image.createGraphics();
perlin.setNoiseQuality(NoiseQuality.BEST);
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
double value = perlin.getValue(x * PERIOD, y * PERIOD, 0);
graphics.setColor(Color.getHSBColor(0, 0, (float) value));
graphics.fillRect(x, y, 1, 1);
}
}
ImageIO.write(image, "PNG", path.toFile());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment