Skip to content

Commit

Permalink
Only considering points along the boundary of the fractal
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpollard committed Nov 16, 2018
1 parent a144bd3 commit d6737f0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 27 deletions.
64 changes: 42 additions & 22 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 22 additions & 5 deletions src/mandelbrot/DimensionFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;

public class DimensionFrame extends JFrame {

Expand Down Expand Up @@ -35,8 +36,9 @@ public DimensionFrame(FractalSet fractalSet, FractalColours colours, DrawingCond

setupComponents(colours, conditions);

this.logOfNoBoxes = new double[8];
this.logOfSideLengths = new double[8];
int size = (int)((Math.log(initialStep)/Math.log(2)) - 1);
this.logOfNoBoxes = new double[size];
this.logOfSideLengths = new double[size];

this.fractalSet.setDimensions(new Dimension(this.getWidth(), this.getHeight()));
this.fractalSet.iterate(false);
Expand Down Expand Up @@ -91,9 +93,24 @@ public void updateGrids() {

if (argandDiagram.getColorAtPixel(boxX, boxY).equals(argandDiagram.colours.getInner())) {

argandDiagram.intersectedBoxes.add(new Point(x, y));
boxes++;
found = true;
ArrayList<Color> neighbours = new ArrayList<>();
if (boxY - 1 >= 0) neighbours.add(argandDiagram.getColorAtPixel(boxX, boxY - 1));
if (boxX + 1 < argandDiagram.getWidth()) neighbours.add(argandDiagram.getColorAtPixel(boxX + 1, boxY));
if (boxY + 1 < argandDiagram.getHeight()) neighbours.add(argandDiagram.getColorAtPixel(boxX, boxY + 1));
if (boxX - 1 >= 0)neighbours.add(argandDiagram.getColorAtPixel(boxX - 1, boxY));

for (Color color: neighbours) {

if (!color.equals(argandDiagram.colours.getInner())) {

argandDiagram.intersectedBoxes.add(new Point(x, y));
boxes++;
found = true;
break;

}

}

}

Expand Down

0 comments on commit d6737f0

Please sign in to comment.