node[] points;
import processing.pdf.*;
String[] file_input;
float x, y, rad, cx, cy, cx2, cy2;
PFont font;
PGraphics pdf;
String file = "02-04";
void setup(){
size(2250,1500);
/*make_pdf("01-16");
make_pdf("01-17");
make_pdf("01-18");
make_pdf("01-19");
make_pdf("01-20");
make_pdf("01-21");
make_pdf("01-22");
make_pdf("02-02");
make_pdf("02-03");
make_pdf("02-04");
make_pdf("02-05");
make_pdf("02-06");
make_pdf("02-07");
make_pdf("02-08");
make_pdf("02-09");
make_pdf("02-10");
make_pdf("02-11");
make_pdf("02-12");
make_pdf("02-13");
make_pdf("02-14");
make_pdf("02-15");
make_pdf("02-16");
make_pdf("02-17");
make_pdf("02-18");
make_pdf("02-19");
make_pdf("02-20");
make_pdf("02-21");
make_pdf("02-22");
make_pdf("02-23");
make_pdf("02-24");
make_pdf("02-25");
make_pdf("02-26");
make_pdf("02-27");
make_pdf("02-28");
make_pdf("03-01");
make_pdf("03-02");
make_pdf("03-03");
make_pdf("03-04");
make_pdf("03-05");
make_pdf("03-06"); */
make_pdf(file);
image(pdf,0,0,2250,1500);
}
void draw(){
}
void keyPressed(){
if(key == 's'){
pdf.save(file + "_" + Integer.toString(day()) + Integer.toString(hour()) + Integer.toString(minute()) + ".png");
println("saved");
}
}
void make_pdf(String file){
println(file);
file_input = loadStrings(file + ".csv");
pdf = createGraphics(9000, 6000, JAVA2D);
points = new node[file_input.length];
for(int i = 0; i < file_input.length; i++){
String[] pieces = split(file_input[i], "\";\"");
pieces[0] = pieces[0].substring(1,pieces[0].length());
pieces[4] = pieces[4].substring(0,pieces[4].length() - 1);
points[i] = new node(parseInt(pieces[0]), pieces[1], parseInt(pieces[2]),
parseInt(pieces[3]), parseFloat(pieces[4]), parseFloat(pieces[5]));
}
pdf.beginDraw();
//size(800,600);
pdf.smooth();
pdf.colorMode(HSB,100);
//bezier nodes
cx = 0;
cy = 0;
cx2 = 0;
cy2 = 0;
//background(0);
font = loadFont("HelveticaNeue-Light-12.vlw");
pdf.textFont(font,12);
pdf.background(100,0,100);
x = -700;
y = 2000 + pdf.height/2;
for(int i = 0; i < points.length; i++){
float x2 = cos(points[i].light) * float(points[i].light)/20.0 + x;
float y2 = sin(points[i].light) * float(points[i].light)/20.0 + y;
pdf.stroke(0,0,10,25);
//pdf.stroke(points[i].db * 100, 100,100);
//pdf.strokeWeight(points[i].temperature/20);
pdf.line(x,y,x2,y2);
points[i].x = x;
points[i].y = y;
x = x2;
y = y2;
}
for(int k = 0; k < points.length;k++){
if (k < points.length-45 && k > 10){
pdf.stroke(0,0,10,25);
pdf.strokeWeight(.1);
pdf.line(points[k].x, points[k].y,points[k+45].x, points[k+45].y);
}
}
for(int j = 0; j < points.length;j++){
if (j < points.length-25 && j > 10){
pdf.stroke(0,0,10,25);
pdf.strokeWeight(1);
pdf.fill(0,0,100,map(points[j].db,0,2,0,100));
pdf.bezier(points[j].x, points[j].y,points[j-10].x,points[j-10].y,points[j+15].x, points[j+15].y,points[j+25].x, points[j+25].y);
}
}
pdf.dispose();
pdf.endDraw();
//pdf.save(file + "_" + Integer.toString(day()) + Integer.toString(hour()) + Integer.toString(minute()) + Integer.toString(second()) + ".png");
//println("saved");
//exit();
//delay(2000);
//pdf.save(file + Integer.toString(day()) + Integer.toString(hour()) + Integer.toString(minute()) + ".png");
}
class node{
int index;
String time;
int light;
int proximity;
float db;
float temperature;
float x,y;
node(int i, String t, int l, int p, float d, float tp){
index = i;
time = t;
light = l;
proximity = p;
db = d;
temperature = tp;
}
}