This commit is contained in:
2022-10-14 17:25:23 +02:00
parent a3cf02fac4
commit a2f0837add
7 changed files with 21707 additions and 24 deletions

View File

@@ -9,7 +9,7 @@ public class Flocon extends Polygon {
super();
}
private int floc(int n, int offset) {
private int floc(int n, int offset, int aoffset) {
if (n < 0) return offset+1;
Vector2 local = ptable[offset].toLocal(ptable[offset+1]);
local.div(3);
@@ -18,34 +18,34 @@ public class Flocon extends Polygon {
ptable[offset+1] = s1;
if (n > 0) {
offset = floc(n-1, offset);
offset = floc(n-1, offset, aoffset);
} else offset++;
Vector2 s2 = Vector2.add(s1, Vector2.rotate(local, -60));
Vector2 s2 = Vector2.add(s1, Vector2.rotate(local, -60 - aoffset));
ptable[offset+1] = s2;
if (n > 0) {
offset = floc(n-1, offset);
offset = floc(n-1, offset, aoffset);
} else offset++;
Vector2 s3 = Vector2.add(s2, Vector2.rotate(local, 60));
Vector2 s3 = Vector2.add(s2, Vector2.rotate(local, 60 + aoffset));
ptable[offset+1] = s3;
if (n > 0) {
offset = floc(n-1, offset);
offset = floc(n-1, offset, aoffset);
} else offset++;
Vector2 s4 = Vector2.add(s3, local);
ptable[offset+1] = s4;
if (n > 0) {
offset = floc(n-1, offset);
offset = floc(n-1, offset, aoffset);
} else offset++;
return offset;
}
public void createFloc(int x, int y, int r, int n) {
public void createFloc(int x, int y, int r, int n, int aoffset) {
int size = 4;
for (int i = 0; i < n; i++) size = size * 4 - 3;
this.ptable = new Vector2[size];
@@ -53,13 +53,13 @@ public class Flocon extends Polygon {
ptable[0] = Vector2.rotate(new Vector2(0, -r),-60).add(new Vector2(x, y));
ptable[1] = Vector2.rotate(new Vector2(0, -r), 60).add(new Vector2(x, y));
offset = floc(n-1, offset);
offset = floc(n-1, offset, aoffset);
ptable[offset+1] = Vector2.rotate(new Vector2(0, -r), 180).add(new Vector2(x, y));
offset = floc(n-1, offset);
offset = floc(n-1, offset, aoffset);
ptable[offset+1] = Vector2.rotate(new Vector2(0, -r), -60).add(new Vector2(x, y));
floc(n-1, offset);
floc(n-1, offset, aoffset);
for (Vector2 v : ptable) {
@@ -76,11 +76,29 @@ public class Flocon extends Polygon {
f.setSize(1200, 1200);
Flocon p = new Flocon();
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 5);
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 4, 0);
FloconPanel fp = new FloconPanel(p);
f.add(new FloconPanel(p));
f.add(fp);
f.setVisible(true);
int a = 0;
while(true) {
try {
Thread.sleep(16);
} catch (Exception e) {
}
a += 1;
p.xpoints = new int[0];
p.ypoints = new int[0];
p.npoints = 0;
p.createFloc(f.getWidth() / 2, f.getHeight() / 2 - 100, 500, 4, a);
fp.repaint();
}
}
}