kopia lustrzana https://github.com/jameshball/osci-render
Cleaned up code and added comments
rodzic
e87739158d
commit
e5460bf096
|
@ -38,6 +38,7 @@ public class AudioPlayer extends Thread {
|
||||||
double drawingProgress = framesDrawn / framesToDraw;
|
double drawingProgress = framesDrawn / framesToDraw;
|
||||||
|
|
||||||
for (int c = 0; c < format.outputs; c++) {
|
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] = shape.nextX(drawingProgress);
|
||||||
((float[]) output)[f * format.outputs + 1] = shape.nextY(drawingProgress);
|
((float[]) output)[f * format.outputs + 1] = shape.nextY(drawingProgress);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +99,11 @@ public class AudioPlayer extends Thread {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Shape currentShape() {
|
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) {
|
public static void setRotateSpeed(double speed) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import shapes.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Node {
|
public class Node {
|
||||||
private Vector location;
|
private Vector location;
|
||||||
|
@ -38,15 +39,15 @@ public class Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object o) {
|
||||||
if (obj == this) {
|
if (this == o) return true;
|
||||||
return true;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
} else if (obj instanceof Node) {
|
Node node = (Node) o;
|
||||||
Node point = (Node) obj;
|
return location.equals(node.location);
|
||||||
|
}
|
||||||
|
|
||||||
return getLocation().equals(point.getLocation());
|
@Override
|
||||||
} else {
|
public int hashCode() {
|
||||||
return false;
|
return Objects.hash(location);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,7 @@ public class Shapes {
|
||||||
List<Shape> polygon = new ArrayList<>();
|
List<Shape> polygon = new ArrayList<>();
|
||||||
|
|
||||||
double theta = angleJump * 2 * Math.PI / sides;
|
double theta = angleJump * 2 * Math.PI / sides;
|
||||||
|
|
||||||
Vector rotated = start.rotate(theta);
|
Vector rotated = start.rotate(theta);
|
||||||
|
|
||||||
polygon.add(new Line(start, rotated, weight));
|
polygon.add(new Line(start, rotated, weight));
|
||||||
|
|
||||||
while (!rotated.equals(start)) {
|
while (!rotated.equals(start)) {
|
||||||
|
|
Ładowanie…
Reference in New Issue