int baseHueB = 200; int baseHueL = 30; int baseHueSpace = 330; boolean debug = false; String[] lines; String[] pieces; String[] paths; String[] steps; float[][] odorField; float maxOdor = -1; float minOdor = 999; String[] labels = {"A","B","C","D","E","F","G","H","J","I"}; int fieldWidth; int fieldHeight; int margin = 80; int drawPathCount = 10; PFont f; int maxStep = -1; int stepThreshold = -1; int lastStepThreshold = -2; boolean highlightStepbar = false; LarvaPath[] larvaPaths; Step maxOdorStep; public void setup() { frameRate(20); lines = loadStrings("odorFieldSimple.tsv"); String line = lines[0]; pieces = split(line,","); fieldWidth = int(pieces[1]); fieldHeight = int(pieces[0]); //size(1024,768); size(fieldWidth + 2 * margin,fieldHeight + 2 * margin); background(0); smooth(); paths = loadStrings("paths.csv"); odorField = new float[fieldHeight][10]; minOdor = float(pieces[2]); maxOdor = float(pieces[3]); maxOdorStep = new Step(float(pieces[5]),float(pieces[4])); ellipseMode(CENTER); rectMode(CENTER); f = loadFont("Helvetica-10.vlw"); textMode(MODEL); textAlign(CENTER); textFont(f); InitializeField(); InitializePaths(); } public void draw() { drawSpace(); drawStepBar(); drawPaths(); } public void InitializeField() { String[] fieldData = lines; for (int i = 1;i maxStep) { maxStep = stepCountCheck; } if (steps.length != stepCountCheck + 3) { println("path error: line " + number); continue;//error exit } else { larvaPaths[i] = new LarvaPath(stepCountCheck,type.equals("B") ? 'B' : 'L',number); //println("Path #"+i+": " + stepCountCheck); for (int k = 0;k < stepCountCheck;k++) { String[] cord = split(steps[k + 3]," "); larvaPaths[i].AppendStep(float(cord[0]),float(cord[1])); } } } } void drawSpace() { background(0); colorMode(HSB,360,100,100,100); rectMode(CORNER); for (int i = 0;i= width/2 - 100) && (mouseX < width/2 + 100) && (mouseY >= 20) && (mouseY < 40)) { highlightStepbar = true; } else { highlightStepbar = false; } if ((mouseX >= width/2 - 100) && (mouseX < width/2 + 100) && (mouseY >= 25) && (mouseY < 35)) { stepThreshold = int(map(mouseX,width/2 - 100, width/2 + 99, 1, maxStep)); } } void mouseReleased() { if ((mouseX >= width/2 - 100) && (mouseX < width/2 + 100) && (mouseY >= 25) && (mouseY < 35)) { stepThreshold = int(map(mouseX,width/2 - 100, width/2 + 99, 1, maxStep)); } highlightStepbar = false; } void keyPressed() { if (key == '+' || key == '=') { lastStepThreshold = stepThreshold; if (stepThreshold < maxStep) { stepThreshold++; } } if (key == '-') { lastStepThreshold = stepThreshold; if (stepThreshold == -1) { stepThreshold = maxStep; } if (stepThreshold > 1) { stepThreshold--; } } if (key >= '0' && key <= '9') { drawPathCount = int(key - '0'); if (drawPathCount == 0) drawPathCount = 10; println("draw path count: " + drawPathCount); } if (key == 'd') { debug = !debug; } } public float TX(float x) { return map(x,0,fieldWidth,0,width - 2 * margin) + margin; } public float TY(float y) { return map(y,0,fieldHeight,0,height - 2 * margin) + margin; }