Created
June 27, 2014 05:39
-
-
Save j-mcc1993/ef75a9227eeac139ee94 to your computer and use it in GitHub Desktop.
Java Fractal Image Generator
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.image.BufferedImage; | |
import javax.imageio.ImageIO; | |
import java.io.File; | |
import java.io.IOException; | |
public class Fractal { | |
public static void main(String[] args) { | |
int width = 2048/2; | |
int height = 1536/2; | |
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); | |
for (int x = 0; x < width; x++) { | |
for (int y = 0; y < height; y++) { | |
image.setRGB(x, y, (x-y)*(x+y)&(x|y)); | |
} | |
} | |
File img = new File("Desktop.png"); | |
try { | |
ImageIO.write(image, "png", img); | |
} catch (IOException e) {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Play around with line 13 to generate different fractals, the idea here is that allowing the color at each pixel to be determined by performing a bitwise boolean operation on the coordinates of that pixel generates a fractal.