optimizations etc

This commit is contained in:
nora 2020-11-17 20:04:02 +01:00
parent 64dc682257
commit 36384cd7bc
7 changed files with 9 additions and 31 deletions

View file

@ -1,7 +0,0 @@
.root {
-fx-background-color: #AAAABA;
}
.label {
-fx-font-size: 25;
}

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<GridPane alignment="center" hgap="10.0" prefHeight="143.0" prefWidth="107.0" stylesheets="/sample/sample.css" vgap="10" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
<Button onAction="#showImage" prefHeight="25.0" prefWidth="110.0" text="Start" GridPane.rowIndex="1" />
<ImageView fx:id="setPreview" fitWidth="1000" preserveRatio="true" />
<columnConstraints>
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints />
<RowConstraints />
</rowConstraints>
</GridPane>

View file

@ -29,7 +29,6 @@ public class CalculationThread extends Thread {
long startTime = System.currentTimeMillis();
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
File f = null;
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
@ -109,14 +108,18 @@ public class CalculationThread extends Thread {
}
}
/**
* Checks wheter the number is in the Mandelbrot set
* @param number The Complex Number to be checked
* @param iterations The amount of iterations the program should do
* @param threshold The threshold for a number not being in the set
* @return -1 if the number is in the set, else it returns the amount of interations before it reached the threshold
*/
int checkMandelbrot(CNumber number, int iterations, double threshold) {
//returns -1 if the number is in the set, returns the number of iterations before it reached the threshold if it is not in the set
// start
CNumber n = new CNumber();
int reached = -1;
// first
n = CNumber.add(n, number);
for (int i = 0; i < iterations; i++) {
@ -131,7 +134,6 @@ public class CalculationThread extends Thread {
}
public int getColorAsInt(int a, int r, int g, int b) {
return (a << 24) | (r << 16) | (g << 8) | b;
}

View file

@ -20,7 +20,7 @@ public class MandelbrotSet {
private double pointY = 0;
private double zoom = 1;
private int width = 1920;
private int threshold = 100;
private int threshold = 1000;
private float ratio = 2 / 3f;
private int threadAmount = 10;

View file

@ -24,7 +24,7 @@ public class Controller {
}
public void startCalculation(ActionEvent actionEvent) {
MandelbrotSet m = new MandelbrotSet(2, 1, 3, 1);
MandelbrotSet m = new MandelbrotSet(2, 3, 3, 10);
m.startMandelbrot();
}
}