Skip to content

Commit 29dbbcb

Browse files
authored
Update Main.java
1 parent 42293b4 commit 29dbbcb

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/Main.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class Panel extends JPanel {
7474
BufferedImage tempImage = null;
7575
boolean zoomChanged = true;
7676
boolean panChanged = true;
77+
double mandelbrotDetail;
7778
Panel()
7879
{
7980
parser = new JEP();
@@ -332,8 +333,8 @@ public double maxDivergence()
332333
return max;
333334
}
334335
public void colorComplex(){
335-
int iStep = 10;
336-
int jStep = 10;
336+
int iStep = (int)menu.complexDetail.getValue();
337+
int jStep = (int)menu.complexDetail.getValue();
337338
int numIStep = (int)(window_screenX/iStep);
338339
int numJStep = (int)(window_screenY/jStep);
339340
//System.out.println(numIStep);
@@ -372,7 +373,7 @@ public void run() {
372373
for(int i = 0; i < numIStep; i++) {
373374
for (int j = 0; j < numJStep; j++) {
374375
Complex m = new Complex(screenToCoordsX(i * iStep), screenToCoordsY(j * jStep));
375-
parser.addVariable("z", m);
376+
parser.addComplexVariable("z", m.re(), m.im());
376377
parser.parseExpression(menu.P.getText());
377378
Complex R = parser.getComplexValue();
378379
//System.out.println(R);
@@ -669,7 +670,7 @@ public void recursiveDraw(int minI, int minJ, int maxI, int maxJ)
669670
{
670671
int area = (maxI-minI + 1) * (maxJ - minJ + 1);
671672
//System.out.println(minI + " " + minJ + " " + maxI + " " + maxJ + " " + area);
672-
if(area < 32)
673+
if(area < 16)
673674
{
674675
for(int tempI = minI; tempI <= maxI; tempI++)
675676
{
@@ -801,11 +802,12 @@ public Complex[] getOrbit(Complex z)
801802
int i = 0;
802803
Complex c = z;
803804
double xsqr = 0; double ysqr = 0;
804-
int maxIter = 1000;
805+
int maxIter = 100;
805806
while(i < maxIter)
806807
{
807808
orbit.add(z);
808-
z = z.mul(z).add(c);
809+
z = z.mul(z);
810+
z = new Complex(z.re() + c.re(), z.im() + c.im());
809811
xsqr = z.re() * z.re();
810812
ysqr = z.im() * z.im();
811813
i++;
@@ -818,11 +820,12 @@ public Color mandelbrotColor(Complex z)
818820
int i = 0;
819821
//double cx = z.re(); double cy = z.im();
820822
//double zx = 0; double zy = 0;
823+
long start = System.nanoTime();
821824
double xsqr = 0; double ysqr = 0;
822825
double x = z.re();
823826
double y = z.im();
824-
int maxIter = 1000;
825-
while(i < maxIter && xsqr + ysqr < 4)
827+
int maxIter = (int)mandelbrotDetail;
828+
while(i < maxIter && xsqr + ysqr < 4)// && System.nanoTime() - start < 100000)
826829
{
827830
/*zy *= zx;
828831
zy += zy + cy;
@@ -870,7 +873,8 @@ public Complex mandelbrot(Complex z)
870873
for(int i = 0; i < 1; i++)
871874
{
872875
//z = (z.power(2).add(c)).power(2).add(c);
873-
z = z.power(2).add(c);
876+
z = z.power(2);
877+
z = new Complex(z.re() + c.re(), z.im() + c.im());
874878
//if(z.abs())
875879
//if(z.)
876880
}
@@ -891,6 +895,7 @@ protected void paintComponent(Graphics gInit) {
891895
//maxCoordX = tempPoint[0];
892896
//maxCoordY = maxCoordX *window_screenY/window_screenX;
893897
//maxCoordY = tempPoint[1];
898+
mandelbrotDetail = menu.mandelbrotDetail.getValue();
894899
g = gInit;
895900
if(!menu.P.getText().contains("z"))
896901
{
@@ -985,4 +990,4 @@ public void uncaughtException(Thread t, Throwable e) {
985990
}
986991
catch(Throwable e){System.out.println(e);}
987992
}
988-
}
993+
}

0 commit comments

Comments
 (0)