Created
February 6, 2017 10:40
-
-
Save Limeth/35d519df9c1e6fc8c4731fc05ccf5937 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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