Added sequential version

This commit is contained in:
Alberto Venturini 2017-09-17 07:33:06 +02:00
parent 12f1744451
commit d440949907
6 changed files with 64 additions and 44 deletions

View file

@ -7,9 +7,6 @@ import java.awt.*;
import java.awt.image.BufferedImage;
public class JuliaSetPanel extends JPanel {
private static int maxIter = 1000;
private static double zoom = 1;
private double cY, cX;
private JuliaSetCalculator juliaSetCalculator;
private JuliaSetConfig config;
@ -26,16 +23,12 @@ public class JuliaSetPanel extends JPanel {
int height = getHeight();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
cX = -0.7;
cY = 0.27015;
double moveX = 0, moveY = 0;
int[][] iterations = juliaSetCalculator.calculate(config);
for(int x = 0; x < width; x++) {
for(int y = 0; y < height; y++) {
float i = iterations[x][y];
int color = Color.HSBtoRGB(((maxIter / i) + 0.5f) % 1, 1, i > 0 ? 1 : 0);
int color = Color.HSBtoRGB(((config.getMaxIterations() / i) + 0.5f) % 1, 1, i > 0 ? 1 : 0);
image.setRGB(x, y, color);
}
}
@ -47,8 +40,7 @@ public class JuliaSetPanel extends JPanel {
public void paintComponent(Graphics gg) {
super.paintComponent(gg);
Graphics2D g = (Graphics2D) gg;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
drawJuliaSet(g);
}