Well, I think the below is an improvement. I went from 500 lines of code to 200 lines and was able to add more to the canvas. I think this might be the best I can get with this at my level but as I keep learning, I hope I can find more efficient ways to code this interpretation of a '60s program!
Thanks all! @hotfooted @GoToLoop @jeremydouglass
IntList start = new IntList();
int ts = 35, txx = 135, txy = 325, fade = 145;
int hexSize = 40, xLoc = 250, yLoc = 75, xSpac = 69, ySpac = 60;
float txf = 2.75, r = PI/1.98;
String[] dancers = {"Dancer A", "Dancer B", "Dancer C", "Dancer D", "Dancer E", "Dancer F", "Dancer G", "Dancer H", "Dancer I", "Dancer J", "Dancer K", "Dancer L"};
int[][] ADJACENTS = {
{0, 1, 5, 10}, // 0, Off Stage Left
{0, 1, 2, 5, 6}, // 1
{1, 2, 3, 6, 7}, //2
{2, 3, 4, 7, 8}, //3
{3, 4, 8, 9, 14}, //4
{0, 1, 5, 6, 10}, //5
{1, 2, 5, 6, 7, 10, 11}, //6
{2, 3, 6, 7, 8, 11, 12}, //7
{3, 4, 7, 8, 9, 12, 13}, //8
{4, 8, 9, 13, 14}, //9
{0, 5, 6, 10, 11}, //10
{6, 7, 10, 11, 12}, //11
{7, 8, 11, 12, 13}, //12
{8, 9, 12, 13, 14}, //13
{4, 9, 13, 14}, // 14, Off Stage Right
};
void setup() {
size(1280, 720);
background(255);
spatialScore();
onstageHex();
offstageHex();
hexagonText();
otherText();
instructions();
}
void spatialScore() {
start.append(new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14});
fill(0);
for (int i = 0; i < 12; i++) {
start.shuffle();
int mes1 = start.get(0); // hexagon location for measure one
int[] mes2get = ADJACENTS[mes1]; // retrieves number from previous measure to produce same or adjacent number for current measure
int mes2 = mes2get[(int)random(mes2get.length)]; // hexagon location for measure two
int[] mes3get = ADJACENTS[mes2]; // retrieves number from previous measure to produce same or adjacent number for current measure
int mes3 = mes3get[(int)random(mes3get.length)]; // hexagon location for measure three and so on for the rest
int[] mes4get = ADJACENTS[mes3];
int mes4 = mes4get[(int)random(mes4get.length)];
int[] mes5get = ADJACENTS[mes4];
int mes5 = mes5get[(int)random(mes5get.length)];
int[] mes6get = ADJACENTS[mes5];
int mes6 = mes6get[(int)random(mes6get.length)];
int[] mes7get = ADJACENTS[mes6];
int mes7 = mes7get[(int)random(mes7get.length)];
int[] mes8get = ADJACENTS[mes7];
int mes8 = mes8get[(int)random(mes8get.length)];
int[] mes9get = ADJACENTS[mes8];
int mes9 = mes9get[(int)random(mes9get.length)];
int[] mes10get = ADJACENTS[mes9];
int mes10 = mes10get[(int)random(mes10get.length)];
int[] mes11get = ADJACENTS[mes10];
int mes11 = mes11get[(int)random(mes11get.length)];
int[] mes12get = ADJACENTS[mes11];
int mes12 = mes12get[(int)random(mes12get.length)];
text(dancers[i], txx - 15 + ts * (i * txf), txy - 25);
text(mes1, txx + ts * (i * txf), txy);
text(mes2, txx + ts * (i * txf), txy + ts);
text(mes3, txx + ts * (i * txf), txy + ts * 2);
text(mes4, txx + ts * (i * txf), txy + ts * 3);
text(mes5, txx + ts * (i * txf), txy + ts * 4);
text(mes6, txx + ts * (i * txf), txy + ts * 5);
text(mes7, txx + ts * (i * txf), txy + ts * 6);
text(mes8, txx + ts * (i * txf), txy + ts * 7);
text(mes9, txx + ts * (i * txf), txy + ts * 8);
text(mes10, txx + ts * (i * txf), txy + ts * 9);
text(mes11, txx + ts * (i * txf), txy + ts * 10);
text(mes12, txx + ts * (i * txf), txy + ts * 11);
}
}
void polygon(float x, float y, float radius, int npoints) {
float angle = TWO_PI / npoints;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius;
float sy = y + sin(a) * radius;
vertex(sx, sy);
}
endShape(CLOSE);
}
void onstageHex() {
noFill();
for (int x = xLoc; x < xLoc + xSpac * 4; x += xSpac) { // Downstage Row of Hexagons
pushMatrix();
translate(x, yLoc);
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
}
for (int x = xLoc - 34; x < xLoc + xSpac * 4; x += xSpac) { // Midstage Row of Hexagons
pushMatrix();
translate(x, yLoc + ySpac);
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
}
for (int x = xLoc; x < xLoc + xSpac * 4; x += xSpac) { // Upstage Row of Hexagons
pushMatrix();
translate(x, yLoc + ySpac * 2);
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
}
}
void offstageHex() {
stroke(fade);
noFill();
pushMatrix();
translate(xLoc - hexSize - 30, yLoc); // Stage Left of 10
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
pushMatrix();
translate(xLoc + 1 + xSpac * 4, yLoc); // Stage Right of 13
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
pushMatrix();
translate(xLoc - hexSize - 64, yLoc + ySpac); // Stage Left of 5
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
pushMatrix();
translate(xLoc + 36 + xSpac * 4, yLoc + ySpac); // Stage Right of 9
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
pushMatrix();
translate(xLoc - hexSize - 30, yLoc + ySpac * 2); // Stage Left of 1
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
pushMatrix();
translate(xLoc + 1 + xSpac * 4, yLoc + ySpac * 2); // Stage Right of 4
rotate(r);
polygon(0, 0, hexSize, 6);
popMatrix();
}
void hexagonText() {
fill(0);
for (int i = 0; i < 4; i++) {
text(i + 1, (xLoc - 3) + xSpac * i, yLoc + 3 + ySpac * 2);
text(i + 10, (xLoc - 8) + xSpac * i, yLoc + 3);
}
for (int i = 0; i < 5; i++) {
text(i + 5, (xLoc - 37) + xSpac * i, yLoc + 3 + ySpac);
}
fill(fade);
text("0", xLoc - hexSize - 33, yLoc + 5); // Stage Left of 10
text("14", xLoc + xSpac * 4 - 8, yLoc + 5); // Stage Right of 13
text("0", xLoc - hexSize - 33 - 34, yLoc + ySpac + 5); // Stage Left of 5
text("14", xLoc + 34 + xSpac * 4 - 8, yLoc + ySpac + 5); // Stage Right of 9
text("0", xLoc - hexSize - 33, yLoc + ySpac * 2 + 5); // Stage Left of 1
text("14", xLoc + xSpac * 4 - 8, yLoc + ySpac * 2 + 5); // Stage Right of 4
}
void otherText() {
fill(0);
text("Measure", 30, 300);
for (int i = 0; i < 12; i++) {
text(i + 1, 50, txy + ts * i);
}
text("Downstage", 115 + xSpac * 3, 20);
text("Upstage", 120 + xSpac * 3, yLoc + 60 + ySpac * 2);
text("Stage Right", 620, 140);
text("Stage Left", 30, 140);
}
void instructions() {
int x = width / 2 + 90;
int y = 50;
noFill();
rect(x - 15, 0, x, y * 5.5);
fill(0);
line(x, y - 23, x + 140, y - 23);
line(0, height / 2 - 55, width, height / 2 - 55);
text("Credits and Instructions", x, y - 25);
text("Reproduction of a program by Francisco Sagasti (March 14, 1968 at PSU.)", x, y);
text("Originally coded using Fortran IV programming language and reinterpreted using\nProcessing 4.0b1 with the support of hotfooted, GoToLoop, and jeremydouglass.", x, y * 2);
text("Hexagons labelled 1 to 13 represents a location onstage. O and 14 represent the offstage.", x, y * 3);
text("Each dancer will occupy a hexagon as noted in their column. Each row represents a measure.", x, y * 4);
text("Dancers can do any movement, interact with others in any way. This is a 'spatial score.'", x, y * 5);
}