Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
21563bb
Quiet down logging from select packages
sul3n3t Jul 22, 2019
43b9288
Only enable streaming logging for project
sul3n3t Jul 22, 2019
cba7723
?
iamh2o Jul 22, 2019
2f18349
Rename test_shows to match style of others
sul3n3t Jul 22, 2019
d3a001f
Import Ponzi color code
sul3n3t Jul 19, 2019
3332dc1
Minor simulator class cleanup
sul3n3t Jul 22, 2019
b6f3832
...
iamh2o Jul 23, 2019
cc2d135
moved color.py from my GD fork to here, fixed the shows trying to nat…
iamh2o Jul 23, 2019
8835e03
missing show
iamh2o Jul 23, 2019
a5fdc0a
fixed RGBW dependency
iamh2o Jul 23, 2019
869e4e5
Edge of strobing ability
iamh2o Jul 23, 2019
3437e89
ok, moving to a branch
iamh2o Jul 23, 2019
1959f04
Fixed simulator to pull RGB values from color object instead of rgb f…
iamh2o Jul 23, 2019
f5b2d6f
Import simplification
sul3n3t Jul 22, 2019
5dc8a7e
__init__ and import changes to make tests easier
sul3n3t Jul 21, 2019
eaf287c
Whitespace and formatting only
sul3n3t Jul 21, 2019
19960e7
Initial test and refactor
sul3n3t Jul 21, 2019
006a512
Bunch of changes, still need mapping of cell to pixel in models
sul3n3t Jul 23, 2019
92dba7c
Implemented old (incorrect) mapping
sul3n3t Jul 24, 2019
cbfacc3
Solve conflicts
sul3n3t Jul 24, 2019
1e7e9fe
More tests and fixes some bugs
sul3n3t Jul 24, 2019
622abf2
Fix shows
sul3n3t Jul 24, 2019
4d6b660
Introduce traversals
sul3n3t Jul 24, 2019
a1192c6
Clearer coords on Cell
sul3n3t Jul 24, 2019
1ccac12
Merge pull request #5 from pyramidscheme/grid-tests
sul3n3t Jul 24, 2019
daf54d7
More type hints
sul3n3t Jul 24, 2019
b8b8601
Remove unnecessary memoization
sul3n3t Jul 24, 2019
39b1737
correct cell mapping for 2 row triangle wirred from bottom left. We …
iamh2o Jul 25, 2019
90624ac
Added some object setters, added hex finding (it's clunky w/out the 2…
iamh2o Jul 25, 2019
60c0029
Unable to auto merge...?
iamh2o Jul 25, 2019
9c187c0
remove embed from being triggered
iamh2o Jul 25, 2019
8a2397b
Rename pixel setter to be clearer
sul3n3t Jul 25, 2019
99b5eca
Warp show
sul3n3t Jul 26, 2019
6cd98ee
Fix Warp show
sul3n3t Jul 26, 2019
3771579
trying to sweep left to right pixel lighting
iamh2o Jul 26, 2019
2628ca4
..
iamh2o Jul 26, 2019
a44db53
mapped 11 row panel. Needs IRL testing
iamh2o Jul 31, 2019
8b73c65
oops- 0 not 1
iamh2o Aug 1, 2019
5737ee2
fixed f'd up first attemt at mapping
iamh2o Aug 1, 2019
d6f97a6
New pixel mapping assuming 4 full strands per triangle
iamh2o Aug 2, 2019
fa255d9
sort of working mapping
iamh2o Aug 3, 2019
4a56955
Add new coordinate to address mapping
silverlyra Aug 4, 2019
b7a57d9
Add new coordinate to address mapping
silverlyra Aug 5, 2019
be12400
Integrate new grid cell code
silverlyra Aug 6, 2019
a15416c
Remove cruft
silverlyra Aug 6, 2019
c624ccc
Merge pull request #10 from pyramidscheme/cell-integration
sul3n3t Aug 7, 2019
2e4c09c
Fix IP detection
silverlyra Aug 8, 2019
ebe1258
Fixes simulator with a little hack on model.set()
sul3n3t Aug 15, 2019
cd04eb0
Pass cell in addition to address to model
sul3n3t Aug 16, 2019
56119bc
small fixes
silverlyra Aug 16, 2019
42a7e7c
Merge pull request #15 from pyramidscheme/aug-15-fixes
silverlyra Aug 16, 2019
69d0ada
Merge pull request #14 from pyramidscheme/fix-simulator
sul3n3t Aug 16, 2019
57eeb2c
ok, I can light pixels again
iamh2o Aug 16, 2019
633ee87
Adds a comment to hexagon()
sul3n3t Aug 16, 2019
3d21499
Geometry fixes
silverlyra Aug 16, 2019
76a01b7
playing with shows
iamh2o Aug 17, 2019
37879ce
Repaired the LeftToRightAndBackAgain Show
iamh2o Aug 17, 2019
8d22aa0
Comment edits to incoporate jem's comments
sul3n3t Aug 17, 2019
1118578
Merge pull request #17 from pyramidscheme/hexagon-comments
sul3n3t Aug 17, 2019
c485262
Merge pull request #19 from pyramidscheme/fix-indexing
sul3n3t Aug 17, 2019
6f8bd4e
Fixes grid tests (and some bugs) in the new paradigm
sul3n3t Aug 16, 2019
56c4e48
Restore warp show
sul3n3t Aug 16, 2019
9df79a0
Merge pull request #16 from pyramidscheme/fix-grid-tests
sul3n3t Aug 18, 2019
f2ab8ec
Merge branch 'master' into warp-show
sul3n3t Aug 18, 2019
f108532
Merge pull request #18 from pyramidscheme/warp-show
sul3n3t Aug 18, 2019
aaa71c6
Adds Coordinate for alternate spatial reasoning
sul3n3t Aug 18, 2019
9b4a490
moving branches
iamh2o Aug 18, 2019
51bea48
Merge pull request #22 from pyramidscheme/coordinates
silverlyra Aug 19, 2019
305aec7
working tendrils show
iamh2o Aug 19, 2019
e010fc3
Merge branch 'master' into jem-shows-tinkering-2
iamh2o Aug 19, 2019
c990d0b
row_length moved
iamh2o Aug 19, 2019
21671ef
some util functions
iamh2o Aug 19, 2019
b04686c
what the fuck is going on....
iamh2o Aug 19, 2019
3672fca
left out crap
iamh2o Aug 19, 2019
efebb13
...
iamh2o Aug 19, 2019
d74f62d
Merge branch 'master' into jem-shows-tinkering-2
iamh2o Aug 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 57 additions & 146 deletions Simulators/TriangleSimulator/TriangleSimulator.pde
Original file line number Diff line number Diff line change
@@ -1,60 +1,36 @@
/*
Playing around with hex drawing, as described at:
http://www.redblobgames.com/grids/hexagons/

Grid shapes are described in arrays of arrays:
{skip_count, fill_count, skip_count ...}
*/

import processing.net.*;
import java.util.regex.*;
Table table;

boolean DRAW_LABELS = true;
//boolean POINTY_TOP = true;
boolean DARK_MODE = false;






// model vars
HexForm honeycomb = null;
HashMap<Integer,String> labels = null;
TriangleForm grid = null;

// network vars
int port = 4444;
Server _server;
StringBuffer _buf = new StringBuffer();

color defaultHexLine() {
return color(255,255,255);
}

color defaultHexFill() {
return color(255,0,255);
}

PVector a = new PVector(400, 100);
PVector b = new PVector(100, 600);
PVector c = new PVector(700, 600);
float hue;

color defaultLineColor = color(255, 255, 255);
color defaultFillColor = color(255, 0, 255);

void setup() {
size(800,700);
rotate(radians(0));
frameRate(30);

// println(PFont.list());
PFont f = createFont("Helvetica", 12, true);
textFont(f, 12);

labels = loadLabels("mapping_tri.csv");

honeycomb = makeSimpleGrid(8,1,500,300);
//honeycomb = makeHexForm(SNOWFLAKE, 50, 50);
grid = makeSimpleGrid();

_server = new Server(this, port);
println("server listening:" + _server);
Expand All @@ -64,49 +40,40 @@ void drawCheckbox(int x, int y, boolean checked) {
int size = 20;
stroke(0);
fill(255);
rect(x,y,size,size);
rect(x, y, size, size);
if (checked) {
line(x,y,x+size,y+size);
line(x+size,y,x,y+size);
line(x, y, x+size, y+size);
line(x+size, y, x, y+size);
}
}


void drawBottomControls() {
// draw a bottom white region
fill(255,255,255);
rect(0,500,500,50);
fill(255, 255, 255);
rect(0, 500, 500, 50);

// draw checkboxes
stroke(0);
fill(255);
drawCheckbox(20,510, DRAW_LABELS); // label checkbox
// drawCheckbox(190,510, POINTY_TOP); // pointy-top checkbox
drawCheckbox(360,510, DARK_MODE); // dark mode

drawCheckbox(20, 510, DRAW_LABELS); // label checkbox

// draw text labels
fill(0);
textAlign(LEFT);
text("Draw Labels", 50, 525);
text("Pointy Top", 220, 525);
text("Dark Mode", 390, 525);
}


void mouseClicked() {
//println("click! x:" + mouseX + " y:" + mouseY);
if (mouseX > 20 && mouseX < 40 && mouseY > 510 && mouseY < 530) {
// clicked draw labels button
DRAW_LABELS = !DRAW_LABELS;
} else if (mouseX > 360 && mouseX < 380 && mouseY > 510 && mouseY < 530) {
DARK_MODE = !DARK_MODE;
}
}

void draw() {
background(250);
drawBottomControls();
honeycomb.draw();
grid.draw();
pollServer();
}

Expand All @@ -125,7 +92,6 @@ void pollServer() {
while (ix > -1) {
String msg = _buf.substring(0, ix);
msg = msg.trim();
//println(msg);
processCommand(msg);
_buf.delete(0, ix+1);
ix = _buf.indexOf("\n");
Expand All @@ -136,47 +102,25 @@ void pollServer() {
}
}

//Pattern cmd_pattern = Pattern.compile("^\\s*(\\d+)\\s+(\\d+),(\\d+),(\\d+)\\s*$");
Pattern cmd_pattern = Pattern.compile("^\\s*(p|b|a|f )\\s+(\\d+)\\s+(\\d+),(\\d+),(\\d+)\\s*$");
Pattern cmd_pattern = Pattern.compile("^\\s*(\\d+)\\s+(\\d+),(\\d+),(\\d+)\\s*$");

void processCommand(String cmd) {
Matcher m = cmd_pattern.matcher(cmd);
if (!m.find()) {
println("ignoring input!");
return;
}
String side = m.group(1);
int cell = Integer.valueOf(m.group(2));
int r = Integer.valueOf(m.group(3));
int g = Integer.valueOf(m.group(4));
int b = Integer.valueOf(m.group(5));
int cell = Integer.valueOf(m.group(1));
int r = Integer.valueOf(m.group(2));
int g = Integer.valueOf(m.group(3));
int b = Integer.valueOf(m.group(4));

honeycomb.setCellColor(cell, color(r,g,b));
grid.setCellColor(cell, color(r,g,b));
}

/*
mappings* Load label mapping file
*/
HashMap<Integer,String> loadLabels(String labelFile) {
HashMap<Integer,String> labels = new HashMap<Integer,String>();
Table table = loadTable(labelFile);

println(table.getRowCount() + " total rows in table");

for (TableRow row : table.rows()) {
int id = row.getInt(0);
String coord = row.getString(1);
labels.put(id, coord);
}
return labels;
}




HexForm makeSimpleGrid(int rows, int cols, int start_x, int start_y) {
HexForm form = new HexForm();
table = loadTable("triangleCellMapping.csv", "header");
TriangleForm makeSimpleGrid() {
TriangleForm form = new TriangleForm();
Table table = loadTable("triangleCellMapping.csv", "header");
for (TableRow row : table.rows()) {
String shape = row.getString("shape");
int x1 = row.getInt("x1");
Expand All @@ -186,59 +130,47 @@ HexForm makeSimpleGrid(int rows, int cols, int start_x, int start_y) {
int x3 = row.getInt("x3");
int y3 = row.getInt("y3");
int id = row.getInt("id");
//triangle(x1,y1,x2,y2,x3,y3);
// print(shape);
form.add(new Hex(x1,y1,x2,y2,x3,y3,id),id);
}
form.add(new Triangle(x1, y1, x2, y2, x3, y3, id), id);
}

return form;
}

class HexForm {
ArrayList<Hex> hexes;
//HashMap<String,Hex> hexesById;

HexForm() {
hexes = new ArrayList<Hex>();
//hexesById = new HashMap<String, Hex>();
class TriangleForm {
ArrayList<Triangle> triangles = new ArrayList<Triangle>();

TriangleForm() {
}

void add(Hex h, int hexId) {
// int hexId = hexes.size();
// if (labels != null) {
// h.setId(labels.get(hexId));
// } else {
// h.setId(String.valueOf(hexId));
// }
print("HEXID:", hexId);
h.setId(hexId);
hexes.add(h);

void add(Triangle triangle, int id) {
print("Triangle ID:", id);
triangle.setId(id);
triangles.add(triangle);
}

int size() {
return hexes.size();
return triangles.size();
}

void draw() {
for (Hex h : hexes) {
h.draw();
for (Triangle triangle : triangles) {
triangle.draw();
}
}

// XXX probably need a better API here!
void setCellColor(int i, color c) {
if (i >= hexes.size()) {
println("invalid offset for HexForm.setColor: i only have " + hexes.size() + " hexes");
// hexes.get(1).setColor(255);

} else {
hexes.get(i).setColor(c);
if (i >= triangles.size()) {
println("invalid offset for HexForm.setColor: i only have " + triangles.size() + " hexes");
return;
}

triangles.get(i).setColor(c);
}

}

class Hex {
class Triangle {
int id = 0; // optional
int x1;
int y1;
Expand All @@ -250,8 +182,8 @@ class Hex {

Integer c; // can store color/int or null

Hex(int x1, int y1,int x2, int y2,int x3, int y3, int id) {
print("CreateHex\n");
Triangle(int x1, int y1,int x2, int y2,int x3, int y3, int id) {
print("CreateTriangle\n");
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
Expand All @@ -267,28 +199,25 @@ class Hex {
this.id = id;
print("pass");
}

void setColor(color c) {
this.c = c;
}


void draw() {
color fill_color = (this.c != null) ? c : defaultHexFill();
color fill_color = (this.c != null) ? c : defaultFillColor;
fill(fill_color);
stroke(defaultHexLine());
stroke(defaultLineColor);

beginShape();
triangle(this.x1,this.y1,this.x2,this.y2,this.x3,this.y3);
triangle(this.x1, this.y1, this.x2, this.y2, this.x3, this.y3);

endShape(CLOSE);

// draw text label
if (DRAW_LABELS && this.id != 0) {
// fill(defaultHexLine());
// if (this.cell == 0) {
fill(defaultHexLine());

fill(defaultLineColor);

if (this.y1 == this.y2) {
textAlign(CENTER);
print(this.id,"pointy");
Expand All @@ -298,26 +227,8 @@ class Hex {
print(this.id,"flat");
text(this.id,this.x1,this.y1+30);
}
// this.cell = 1;
// } else {
// textAlign(BOTTOM);
// text(this.id,this.x1+20,this.y3);
// this.cell = 0;
// }
// if (this.id % 2 == 0) {
// textAlign(CENTER);
// text(this.id,this.x1,this.y1);/
//
// } else {
// textAlign(CENTER);
// text(this.id,this.x3+5,this.y3);
//
// }

// print(this.id, this.x1, this.y2,this.x2, this.y2,this.x3, this.y3 );
}

noFill();


}
}
Loading