Created
March 4, 2019 22:54
-
-
Save dashaw92/7140916458e4aa3f9a140c6d28cc650e to your computer and use it in GitHub Desktop.
Program that generates a w95-esque tileable wallpaper
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
import java.awt.*; | |
import java.awt.image.*; | |
import java.io.File; | |
import java.util.Random; | |
import javax.imageio.ImageIO; | |
public class Wallpaper { | |
public static void main(String[] args) throws Exception { | |
BufferedImage ig = new BufferedImage(255, 255, BufferedImage.TYPE_INT_ARGB); | |
Graphics g = ig.createGraphics(); | |
for(int x = 0; x < ig.getWidth(); x++) { | |
for(int y = 0; y < ig.getHeight(); y++) { | |
Color c = new Color(0, 0, getColor(x,y)); | |
g.setColor(c); | |
g.drawRect(x, y, 1, 1); | |
} | |
} | |
ImageIO.write(ig, "png", new File("wallpaper.png")); | |
} | |
private static Random rand = new Random(); | |
private static int getColor(int x, int y) { | |
int blue = x ^ y << rand.nextInt(50); | |
blue = Math.max(0, blue) % 255; | |
if(blue > 100) { | |
blue = 0; | |
} | |
return blue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment