class StatefulTile { final Cell cell ; float x, y ; final int col, row ; float rot = 0, scalex = 1, scaley = 1 ; // rot is in radians float tox, toy ; float torot = 0, toscalex = 1, toscaley = 1 ; boolean rotateB4scale = true ; StatefulTile(Cell cell, int col, int row, float x, float y, float rot, float scalex, float scaley, boolean rotateB4scale) { this.cell = cell ; this.col = col ; this.row = row ; this.x = this.tox = x ; this.y = this.toy = y ; this.rot = this.torot = rot ; this.scalex = this.toscalex = scalex ; this.scaley = this.toscaley = scaley ; this.rotateB4scale = rotateB4scale ; } void display(int w, int h) { pushMatrix(); translate(x, y); if (! rotateB4scale) { if (scalex != 1 || scaley != 1) { scale(scalex, scaley); } } if (rot != 0) { rotate(rot); } if (rotateB4scale) { if (scalex != 1 || scaley != 1) { scale(scalex, scaley); } } cell.display(0,0,w,h); popMatrix(); } void display() { display(cell.width, cell.height); } boolean advance() { // return true on a state change boolean advanced = false ; if (tox < x) { x -= translateRate ; if (x < tox) { x = tox ; } advanced = true ; } else if (tox > x) { x += translateRate ; if (x > tox) { x = tox ; } advanced = true ; } if (toy < y) { y -= translateRate ; if (y < toy) { y = toy ; } advanced = true ; } else if (toy > y) { y += translateRate ; if (y > toy) { y = toy ; } advanced = true ; } if (torot < rot) { rot -= rotateRate ; if (rot < torot) { rot = torot ; } advanced = true ; } else if (torot > rot) { rot += rotateRate ; if (rot > torot) { rot = torot ; } advanced = true ; } if (toscalex < scalex) { scalex -= scaleRate ; if (scalex < toscalex) { scalex = toscalex ; } advanced = true ; } else if (toscalex > scalex) { scalex += scaleRate ; if (scalex > toscalex) { scalex = toscalex ; } advanced = true ; } if (toscaley < scaley) { scaley -= scaleRate ; if (scaley < toscaley) { scaley = toscaley ; } advanced = true ; } else if (toscaley > scaley) { scaley += scaleRate ; if (scaley > toscaley) { scaley = toscaley ; } advanced = true ; } return advanced ; } } /* Interface for the various tessellators. */ interface Tiler { /** * Return a list of all the cell placements. * When isDisplay is true, display them on the display as well. * When isDisplay is false, this method is used to build a future display. **/ List tileDisplay(int variant, boolean isDisplay) ; int getNumberOfVariants(); } abstract class SymmetryTiler implements Tiler { protected Cell cell ; SymmetryTiler(Cell mycell) { cell = mycell ; } } class TranslationSymmetry_p1 extends SymmetryTiler implements Tiler { TranslationSymmetry_p1(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 1 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width, col++) { for (int row = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height, row++) { if (isDisplay) cell.display(x, y); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); } } printname("TranslationSymmetry_p1_" + variant); return built ; } } class HalfTurnRotationSymmetry_p2 extends SymmetryTiler implements Tiler { HalfTurnRotationSymmetry_p2(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 3 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); if (variant == 0) { // horizontal pairing for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width * 2, col+=2) { for (int row = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height, row++) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); translate(cell.width, 0); rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, PI, 1, 1, true)); popMatrix(); } } } else if (variant == 1) { // vertical pairing for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width, col++) { for (int row = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row += 2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); translate(0, cell.height); rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, PI, 1, 1, true)); popMatrix(); } } } else { // horizontal AND vertical pairing for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width*2, col+=2) { for (int row = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row+= 2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); if (isDisplay) cell.display(round(cell.width), round(cell.height)); built.add(new StatefulTile(cell, col+1, row+1, x+round(cell.width), y+round(cell.height), 0, 1, 1, true)); pushMatrix(); translate(0, cell.height); rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, PI, 1, 1, true)); popMatrix(); pushMatrix(); translate(cell.width, 0); rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, PI, 1, 1, true)); popMatrix(); popMatrix(); } } } printname("HalfTurnRotationSymmetry_p2_ " + variant); return built ; } } class QuarterTurnRotationSymmetry_p4 extends SymmetryTiler implements Tiler { QuarterTurnRotationSymmetry_p4(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 2 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); if (variant == 0) { // go clockwise, with upper left not rotated for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width*2, col+=2) { for (int row = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); pushMatrix(); translate(cell.width, 0); rotate(HALF_PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, HALF_PI, 1, 1, true)); popMatrix(); pushMatrix(); translate(cell.width, cell.height); rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row+1, x+cell.width, y+cell.height, PI, 1, 1, true)); popMatrix(); pushMatrix(); translate(0, cell.height); rotate(-HALF_PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, -HALF_PI, 1, 1, true)); popMatrix(); popMatrix(); } } } else { // counterclockwise, unrotated cell is in upper right for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width*2, col+=2) { for (int row=0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(round(cell.width), 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, 0, 1, 1, true)); pushMatrix(); rotate(-HALF_PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, -HALF_PI, 1, 1, true)); popMatrix(); pushMatrix(); translate(cell.width, cell.height); rotate(HALF_PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row+1, x+cell.width, y+cell.height, HALF_PI, 1, 1, true)); popMatrix(); pushMatrix(); translate(0, cell.height); rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, PI, 1, 1, true)); popMatrix(); popMatrix(); } } } printname("QuarterTurnRotationSymmetry_p4_ " + variant); return built ; } } class GlideSymmetry_pg extends SymmetryTiler implements Tiler { GlideSymmetry_pg(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 3 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); if (variant == 0) { // horizontal pairing for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width * 2, col+=2) { for (int row = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height, row++) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); translate(cell.width, 0); scale(1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, 0, 1, -1, true)); popMatrix(); } } printname("GlideSymmetry_pg_ " + variant); } else if (variant == 1) { // vertical pairing for (int col=0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width, col++) { for (int row=0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); translate(0, cell.height); scale(-1, 1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, 0, -1, 1, true)); popMatrix(); } } printname("GlideSymmetry_pg_ " + variant); } else { for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width*2, col+=2) { for (int row=0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); pushMatrix(); translate(cell.width, 0); scale(1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, 0, 1, -1, true)); popMatrix(); pushMatrix(); translate(0, cell.height); scale(-1, 1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, 0, -1, 1, true)); popMatrix(); pushMatrix(); translate(cell.width, cell.height); scale(-1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row+1, x+cell.width, y+cell.height, 0, -1, -1, true)); popMatrix(); popMatrix(); } } printname("DoubleGlideSymmetry_pg_ " + variant); } return built ; } } class MirrorSymmetry_pm extends SymmetryTiler implements Tiler { MirrorSymmetry_pm(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 4 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); if (variant == 0) { // horizontal pairing for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width * 2, col+=2) { for (int row = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height, row++) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); translate(cell.width, 0); scale(-1, 1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, 0, -1, 1, true)); popMatrix(); } } printname("MirrorSymmetry_pm_ " + variant); } else if (variant == 1) { // vertical pairing for (int col = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width, col++) { for (int row=0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); translate(0, cell.height); scale(1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, 0, 1, -1, true)); popMatrix(); } } printname("MirrorSymmetry_pm_ " + variant); } else if (variant == 2) { // horizontal AND vertical pairing for (int col=0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width*2, col+=2) { for (int row=0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, 0, 1, 1, true)); pushMatrix(); translate(cell.width, cell.height); scale(-1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row+1, x+cell.width, y+cell.height, 0, -1, -1, true)); popMatrix(); pushMatrix(); translate(0, cell.height); scale(1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, 0, 1, -1, true)); popMatrix(); pushMatrix(); translate(cell.width, 0); scale(-1,1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, 0, -1, 1, true)); popMatrix(); popMatrix(); } } printname("DoubleMirrorSymmetry_pm_ " + variant); } else { for (int col=0, i = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width*2, i = (i+1) & 1, col+=2) { for (int row=0, y = int(cell.height/2) ; y <= height+cell.height*4 ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y-i*cell.height); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y-i*cell.height, 0, 1, 1, true)); pushMatrix(); translate(cell.width, cell.height); scale(-1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row+1, x+cell.width, y+cell.height-i*cell.height, 0, -1, -1, true)); popMatrix(); pushMatrix(); translate(0, cell.height); scale(1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height-i*cell.height, 0, 1, -1, true)); popMatrix(); pushMatrix(); translate(cell.width, 0); scale(-1,1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y-i*cell.height, 0, -1, 1, true)); popMatrix(); popMatrix(); } } printname("StaggeredDoubleMirrorSymmetry_pm_ " + variant); } return built ; } } class StaggeredMirrorSymmetry_cm extends SymmetryTiler implements Tiler { StaggeredMirrorSymmetry_cm(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 2 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); if (variant == 0) { // horizontal pairing for (int col=0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width * 2,col+=2) { for (int row=0, i = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height, i = (i+1) & 1, row++) { pushMatrix(); translate(x-i*cell.width,y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x-i*cell.width, y, 0, 1, 1, true)); translate(cell.width, 0); scale(-1, 1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width-i*cell.width, y, 0, -1, 1, true)); popMatrix(); } } } else { // vertical pairing for (int col=0, i = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width, i = (i+1) & 1, col++) { for (int row=0, y = int(cell.height/2) ; y <= height+cell.height*4 ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y-i*cell.height); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y-i*cell.height, 0, 1, 1, true)); translate(0, cell.height); scale(1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height-i*cell.height, 0, 1, -1, true)); popMatrix(); } } } printname("StaggeredMirrorSymmetry_cm_ " + variant); return built ; } } class GlidedStaggeredMirrorSymmetry_pmg extends SymmetryTiler implements Tiler { GlidedStaggeredMirrorSymmetry_pmg(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 2 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); if (variant == 0) { // horizontal pairing for (int col=0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width * 2, col+=2) { for (int row=0, i = 0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height, i = (i+1) & 1, row++) { pushMatrix(); translate(x,y); pushMatrix(); if (i == 1) rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, (i == 1)?PI:0, 1, 1, true)); popMatrix(); pushMatrix(); translate(cell.width, 0); if (i == 1) rotate(PI); scale(-1, 1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+1, row, x+cell.width, y, (i == 1)?PI:0, -1, 1, true)); popMatrix(); popMatrix(); } } } else { // vertical pairing for (int col=0, i = 0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width, i = (i+1) & 1, col++) { for (int row=0, y = int(cell.height/2) ; y <= height+cell.height*4 ; y += cell.height*2, row+=2) { pushMatrix(); translate(x,y); pushMatrix(); if (i == 1) rotate(PI); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y, (i == 1)?PI:0, 1, 1, true)); popMatrix(); pushMatrix(); translate(0, cell.height); if (i == 1) rotate(PI); scale(1, -1); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row+1, x, y+cell.height, (i == 1)?PI:0, 1, -1, true)); popMatrix(); popMatrix(); } } } printname("GlidedStaggeredMirrorSymmetry_pmg_ " + variant); return built ; } } class FourRotationsMirrorSymmetry_p4g extends SymmetryTiler implements Tiler { FourRotationsMirrorSymmetry_p4g(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 4 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); float referenceRotation = variant * -HALF_PI ; int [][] blockTranslate = { // to get to reference cell for that block, {X, Y} {0, 0}, {3, 0}, {2, 2}, {1, 2} }; int [][][] cellTranslate = { // 2D translate with index [block][cell][X=0, Y=1] { // block 0 and 2 {0, 0}, {1, 0}, {1, 1}, {0, 1} }, { // block 1 and 3 {0, 0}, {-1, 0}, {-1, 1}, {0, 1} } } ; // col, row calcs: // block 0: {0, 0}, {1, 0}, {1, 1}, {0, 1} // block 1: {3, 0}, {2, 0}, {2, 1}, {3, 1} // block 2: {2, 2}, {3, 2}, {3, 3}, {2, 3} // block 3: {1, 2}, {0, 2}, {0, 3}, {1, 3} for (int col=0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width * 4, col+=4) { for (int row=0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height * 4, row += 4) { pushMatrix(); translate(x, y); for (int block = 0 ; block < 4 ; block++) { int b = block & 1 ; pushMatrix(); translate(blockTranslate[block][0]*cell.width, blockTranslate[block][1]*cell.height); for (int cellblk = 0 ; cellblk < 4 ; cellblk++) { pushMatrix(); translate(cellTranslate[b][cellblk][0]*cell.width, cellTranslate[b][cellblk][1]*cell.height); //rotate(referenceRotation+cellblk*HALF_PI); if (block == 1 || block == 3) { scale(-1, 1); // flip before rotate } rotate(referenceRotation+cellblk*HALF_PI); if (isDisplay) cell.display(0, 0); int columnoffset = blockTranslate[block][0] + cellTranslate[b][cellblk][0] ; int rowoffset = blockTranslate[block][1] + cellTranslate[b][cellblk][1] ; // THIS WAS A DEBUG< BUT IT MAKES A COOL FEATURE // columnoffset = block ; rowoffset = cellblk ; built.add(new StatefulTile(cell, col+columnoffset, row+rowoffset, x+blockTranslate[block][0]*cell.width +cellTranslate[b][cellblk][0]*cell.width, y+blockTranslate[block][1]*cell.height+cellTranslate[b][cellblk][1]*cell.height, referenceRotation+cellblk*HALF_PI, ((block == 1 || block == 3) ? -1 : 1), 1, false)); popMatrix(); } popMatrix(); } popMatrix(); } } printname("FourRotationsMirrorSymmetry_p4g_ " + variant); return built ; } } class TraditionalBlockSymmetry_p4m extends SymmetryTiler implements Tiler { TraditionalBlockSymmetry_p4m(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 1 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); // horizontal pairing int [][] translations = { // [subtile][X|Y] {0, 0}, {1, 0}, {1, 1}, {0, 1} }; for (int col=0, x = int(cell.width/2) ; x <= width+2*cell.width ; x += cell.width * 2, col+=2) { for (int row=0, y = int(cell.height/2) ; y <= height+2*cell.height ; y += cell.height * 2,row+=2) { for (int subtile = 0 ; subtile < 4 ; subtile++) { pushMatrix(); translate(x+translations[subtile][0]*cell.width, y+translations[subtile][1]*cell.height); rotate(HALF_PI * subtile); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col+translations[subtile][0],row+translations[subtile][1], x+translations[subtile][0]*cell.width, y+translations[subtile][1]*cell.height, HALF_PI * subtile,1,1,true)); popMatrix(); } } } printname("TraditionalBlockSymmetry_p4m_ " + variant); return built ; } } class HexSymmetry_px extends SymmetryTiler implements Tiler { // Derived from SixRotationSymmetry_p6 with an assortment of rotations & reflections HexSymmetry_px(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 12 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); // horizontal pairing float offset = .75 * cell.width; for (int col = 0, i = 0, x = int(-cell.width/2) ; x <= width+2*cell.width ; x += offset, i = (i+1)&1, col++) { for (int row = 0, j = 0, y = int(-cell.height/2) ; y <= height+2*cell.height ; y += cell.height, j = (j+1)&1, row++) { pushMatrix(); int reflectx = 1, reflecty = 1 ; translate(x, y-i*cell.height/2); if ((variant & 1) == 1 && i != j) { reflectx = -1 ; } if (((variant >> 1) & 1) == 1 && i != j) { reflecty = -1 ; } if (variant > 5) { if (reflectx != 1 || reflecty != 1) { scale(reflecty, reflectx); } } int rotter = variant / 4 ; if (rotter != 0) { rotate(rotter * PI / 3.0); } if (variant < 6) { if (reflectx != 1 || reflecty != 1) { scale(reflecty, reflectx); } } if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, col, row, x, y-i*cell.height/2, ((rotter != 0) ? (rotter * PI / 3.0) : 0), reflecty, reflectx, variant < 6)); popMatrix(); } } printname("HexSymmetry_px_ " + variant); return built ; } } /** DEBUG TODO NOT RECTANGLE *************** class ThreeRotationSymmetry_p3 extends SymmetryTiler implements Tiler { ThreeRotationSymmetry_p3(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 1 ; } List tileDisplay(int variant, boolean isDisplay) { // horizontal pairing List built = new LinkedList(); float [][] translations = { // [subtile][X|Y] {0, 0}, {1, 0}, {.5, .5} }; for (int x = int(cell.width/2) ; x <= width+cell.width ; x += cell.width * 2) { for (int i = 0, y = int(-cell.height/2) ; y <= height+cell.height ; y += cell.height, i = (i+1)&1) { for (int subtile = 0 ; subtile < 3 ; subtile++) { pushMatrix(); translate(x-i*cell.width+translations[subtile][0]*cell.width, y+translations[subtile][1]*cell.height); rotate(TWO_PI / 3.0 * subtile); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, round(x-i*cell.width+translations[subtile][0]*cell.width), round(y+translations[subtile][1]*cell.height), TWO_PI / 3.0 * subtile,1,1)); popMatrix(); } } } printname("ThreeRotationSymmetry_p3_ " + variant); return built ; } } class SixRotationSymmetry_p6 extends SymmetryTiler implements Tiler { SixRotationSymmetry_p6(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 1 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); // horizontal pairing float offset = .75 * cell.width; for (int i = 0, x = int(-cell.width/2) ; x <= width+cell.width ; x += offset, i = (i+1)&1) { for (int y = int(-cell.height/2) ; y <= height+cell.height ; y += cell.height) { pushMatrix(); translate(x, y-i*cell.height/2); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, x, y-i*cell.height/2, 0,1,1)); popMatrix(); } } printname("SixRotationSymmetry_p6_ " + variant); return built ; } } class MirrorThreeRotationSymmetry_p3 extends SymmetryTiler implements Tiler { MirrorThreeRotationSymmetry_p3(Cell mycell) { super(mycell); } // Code for MirrorThreeRotationSymmetry_p3 same as // SixRotationSymmetry_p6, but the hexagonal tile is composed // from the same equilateral triangle differently, using reflection int getNumberOfVariants() { return 1 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); // horizontal pairing float offset = .75 * cell.width; for (int i = 0, x = int(-cell.width/2) ; x <= width+cell.width ; x += offset, i = (i+1)&1) { for (int y = int(-cell.height/2) ; y <= height+cell.height ; y += cell.height) { pushMatrix(); translate(x, y-i*cell.height/2); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, x, y-i*cell.height/2, 0,1,1)); popMatrix(); } } printname("MirrorThreeRotationSymmetry_p3_ " + variant); return built ; } } class KaleidoscopeSymmetry_p6m extends SymmetryTiler implements Tiler { KaleidoscopeSymmetry_p6m(Cell mycell) { super(mycell); } // Code for KaleidoscopeSymmetry_p6m same as // MirrorThreeRotationSymmetry_p3 and // SixRotationSymmetry_p6, but the hexagonal tile is composed // from the same equilateral triangle differently, using reflection int getNumberOfVariants() { return 1 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); // horizontal pairing float offset = .75 * cell.width; for (int i = 0, x = int(-cell.width/2) ; x <= width+cell.width ; x += offset, i = (i+1)&1) { for (int y = int(-cell.height/2) ; y <= height+cell.height ; y += cell.height) { pushMatrix(); translate(x, y-i*cell.height/2); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, x, y-i*cell.height/2, 0,1,1)); popMatrix(); } } printname("KaleidoscopeSymmetry_p6m_ " + variant); return built ; } } class ThreeRotationsMirrorSymmetry_p3m extends SymmetryTiler implements Tiler { ThreeRotationsMirrorSymmetry_p3m(Cell mycell) { super(mycell); } int getNumberOfVariants() { return 1 ; } List tileDisplay(int variant, boolean isDisplay) { List built = new LinkedList(); // horizontal pairing float xoffset = .67 * cell.width; float yoffset = 1 * cell.height ; for (int x = int(-cell.width/2) ; x <= width+cell.width ; x += xoffset) { for (int i = 0, y = int(-cell.height/2) ; y <= height+cell.height ; y += yoffset, i = (i+1)&1) { pushMatrix(); translate(x-i*cell.width/2, y); if (isDisplay) cell.display(0, 0); built.add(new StatefulTile(cell, x-i*cell.width/2, y, 0,1,1)); popMatrix(); } } printname("ThreeRotationsMirrorSymmetry_p3m_ " + variant); return built ; } } DEBUG TODO NOT RECTANGLE ***************/