kopia lustrzana https://github.com/jameshball/osci-render
Added support for drawing 'polygrams'
rodzic
d2c668d057
commit
8bf4eb7613
|
@ -11,32 +11,16 @@ public class AudioClient {
|
|||
AudioPlayer.FORMAT = new XtFormat(new XtMix(sampleRate, XtSample.FLOAT32), 0, 0, 2, 0);
|
||||
|
||||
for (int i = 2; i < 7; i++) {
|
||||
AudioPlayer.addLines(generatePolygon(i, 0.5));
|
||||
AudioPlayer.addLines(Shapes.generatePolygon(i, 0.5));
|
||||
}
|
||||
AudioPlayer.setRotateSpeed(0.4);
|
||||
|
||||
//AudioPlayer.addLines(Shapes.generatePolygram(5, 4, new Point(0, 0.4).rotate(Math.PI / 5)));
|
||||
|
||||
AudioPlayer.setRotateSpeed(0.8);
|
||||
|
||||
player.start();
|
||||
while (true) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Line> generatePolygon(int sides, double scale) {
|
||||
List<Line> polygon = new ArrayList<>();
|
||||
|
||||
double theta = 2 * Math.PI / sides;
|
||||
|
||||
Point start = new Point(scale, scale);
|
||||
Point rotated = start.rotate(theta);
|
||||
|
||||
polygon.add(new Line(start, rotated));
|
||||
|
||||
while (!rotated.equals(start)) {
|
||||
polygon.add(new Line(rotated.copy(), rotated.rotate(theta)));
|
||||
|
||||
rotated = rotated.rotate(theta);
|
||||
}
|
||||
|
||||
return polygon;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Shapes {
|
||||
public static List<Line> generatePolygram(int sides, int angleJump, Point start) {
|
||||
List<Line> polygon = new ArrayList<>();
|
||||
|
||||
double theta = angleJump * Math.PI / sides;
|
||||
|
||||
Point rotated = start.rotate(theta);
|
||||
|
||||
polygon.add(new Line(start, rotated));
|
||||
|
||||
while (!rotated.equals(start)) {
|
||||
polygon.add(new Line(rotated.copy(), rotated.rotate(theta)));
|
||||
|
||||
rotated = rotated.rotate(theta);
|
||||
}
|
||||
|
||||
return polygon;
|
||||
}
|
||||
|
||||
public static List<Line> generatePolygram(int sides, int angleJump, double scale) {
|
||||
return generatePolygram(sides, angleJump, new Point(scale, scale));
|
||||
}
|
||||
|
||||
public static List<Line> generatePolygon(int sides, Point start) {
|
||||
return generatePolygram(sides, 2, start);
|
||||
}
|
||||
|
||||
public static List<Line> generatePolygon(int sides, double scale) {
|
||||
return generatePolygon(sides, new Point(scale, scale));
|
||||
}
|
||||
}
|
Ładowanie…
Reference in New Issue