Cleaned up code and added comments

pull/35/head
James Ball 2020-02-06 11:37:32 +00:00
rodzic e87739158d
commit e5460bf096
3 zmienionych plików z 16 dodań i 12 usunięć

Wyświetl plik

@ -38,6 +38,7 @@ public class AudioPlayer extends Thread {
double drawingProgress = framesDrawn / framesToDraw;
for (int c = 0; c < format.outputs; c++) {
// Even output indexes refer to first channel, odd indexes refer to second channel.
((float[]) output)[f * format.outputs] = shape.nextX(drawingProgress);
((float[]) output)[f * format.outputs + 1] = shape.nextY(drawingProgress);
}
@ -98,7 +99,11 @@ public class AudioPlayer extends Thread {
}
private static Shape currentShape() {
return shapes.get(currentShape % shapes.size());
if (currentShape >= shapes.size()) {
currentShape -= shapes.size();
}
return shapes.get(currentShape);
}
public static void setRotateSpeed(double speed) {

Wyświetl plik

@ -4,6 +4,7 @@ import shapes.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class Node {
private Vector location;
@ -38,15 +39,15 @@ public class Node {
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
} else if (obj instanceof Node) {
Node point = (Node) obj;
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Node node = (Node) o;
return location.equals(node.location);
}
return getLocation().equals(point.getLocation());
} else {
return false;
}
@Override
public int hashCode() {
return Objects.hash(location);
}
}

Wyświetl plik

@ -8,9 +8,7 @@ public class Shapes {
List<Shape> polygon = new ArrayList<>();
double theta = angleJump * 2 * Math.PI / sides;
Vector rotated = start.rotate(theta);
polygon.add(new Line(start, rotated, weight));
while (!rotated.equals(start)) {