summaryrefslogtreecommitdiff
path: root/vodaviz.pde
diff options
context:
space:
mode:
authorgit@eclectronics.org <git@eclectronics.org@eclectronics.org>2012-02-17 13:56:30 +0000
committergit@eclectronics.org <git@eclectronics.org@eclectronics.org>2012-02-17 13:56:30 +0000
commit6b47aa628182fc6dfa376113145d8f8b8bb047d1 (patch)
treeb281054b0a6e09273e85aa3d93ebdd6051216213 /vodaviz.pde
parentfada66e0ff98ce98c50d6e9a5cc1f449a8a87296 (diff)
load/save data working
Diffstat (limited to 'vodaviz.pde')
-rw-r--r--vodaviz.pde274
1 files changed, 140 insertions, 134 deletions
diff --git a/vodaviz.pde b/vodaviz.pde
index f0c8d87..566276e 100644
--- a/vodaviz.pde
+++ b/vodaviz.pde
@@ -193,8 +193,8 @@ void setup(){
println("vodaviz v0.21");
RG.init(this);
- //mode="PDF";
- if (mode=="PDF") size(832,220,PDF, "vodaviz_bg_160212.pdf"); //P3D); //832,220); //nb pdf is 800x600
+ mode="PDF";
+ if (mode=="PDF") size(832,220,PDF, "vodaviz_circles_170212.pdf"); //P3D); //832,220); //nb pdf is 800x600
else size(832,220); //,PDF, "testoutput.pdf"); //P3D); //832,220); //nb pdf is 800x600
// C. 33 - M. 3 - Y. 0 - K. 0
@@ -220,10 +220,10 @@ void setup(){
float bezierfract=0.25;
bstroke = new bezierstroke(startsize,endsize,linewidth,mpfract,raisefract,bezierfract);
- startsize=.2;
- endsize=.1;
- float[] transpos={0.0,0.15,0.85,1.0};
- float[] transamt={0.5,0.2,0.2,0.5};
+ startsize=2;
+ endsize=.2;
+ float[] transpos={0.0,0.25,0.75,1.0};
+ float[] transamt={0.5,0.05,0.05,0.5};
color col=color(0,0,0);
gstroke=new gradientstroke3D(startsize,endsize,transpos,transamt,col,smap);
@@ -232,7 +232,7 @@ void setup(){
Ireland=new bitmapcountry("Ireland",0,0,shp.children[0]);
Ireland.analyse(18.279,746.302,109,374.293);
data=new csvloader("calls.csv");
- calls=new calldata(data.data,shp);
+ calls=new calldata(data.data,shp,"countries5.xml",this);
background(255,255,255);
noFill();
@@ -255,144 +255,150 @@ int i=0;
int j=0;
void draw() {
- noStroke();
-
- float hw=getWidth()/2;
- float hh=getHeight()/2;
+ if (calls.loaded) { // wait for 1st xmlevent
+ noStroke();
+
+ float hw=getWidth()/2;
+ float hh=getHeight()/2;
+
+ if (i==0) {
+ //image(lightmap,0,0,getWidth(),getHeight());
+ //fill(bg);
+ //rect(0,0,width,height);
+ //background(0);
+
+ if (false) { //render lightmap in 3D
+ float pw=0.5/lightmap.width;
+ float ph=0.5/lightmap.height;
+ for (int j=0;j<lightmap.width;j++) {
+ for (int k=0;k<lightmap.height;k++) {
+ fill(lightmap.get(j,k));
+ float u=(((float)j)/lightmap.width)-0.5;
+ float v=(((float)k)/lightmap.height)-0.5;
+ RPoint p0=smap.per(ptrans.form(new RPoint((u-pw)*TWO_PI,(v+ph)*PI)),4);
+ RPoint p1=smap.per(ptrans.form(new RPoint((u+pw)*TWO_PI,(v+ph)*PI)),4);
+ RPoint p2=smap.per(ptrans.form(new RPoint((u-pw)*TWO_PI,(v-ph)*PI)),4);
+ RPoint p3=smap.per(ptrans.form(new RPoint((u+pw)*TWO_PI,(v-ph)*PI)),4);
+ quad(p0.x+hw,p0.y+hh,p1.x+hw,p1.y+hh,p3.x+hw,p3.y+hh,p2.x+hw,p2.y+hh); //clockwise
+ //quad(p0.x,p0.y,p1.x,p1.y,p3.x,p3.y,p2.x,p2.y); //clockwise
+ }
+ }
+ }
+ }
+ //fill(fg);
+
+ //pick a random colour
+ //fg=color(random(150)+10,random(150)+10,random(150)+10);
+ stroke(fg);
+ //stroke(0,0,0,50);
- if (i==0) {
- //image(lightmap,0,0,getWidth(),getHeight());
- //fill(bg);
- //rect(0,0,width,height);
- //background(0);
-
- if (false) { //render lightmap in 3D
- float pw=0.5/lightmap.width;
- float ph=0.5/lightmap.height;
- for (int j=0;j<lightmap.width;j++) {
- for (int k=0;k<lightmap.height;k++) {
- fill(lightmap.get(j,k));
- float u=(((float)j)/lightmap.width)-0.5;
- float v=(((float)k)/lightmap.height)-0.5;
- RPoint p0=smap.per(ptrans.form(new RPoint((u-pw)*TWO_PI,(v+ph)*PI)),4);
- RPoint p1=smap.per(ptrans.form(new RPoint((u+pw)*TWO_PI,(v+ph)*PI)),4);
- RPoint p2=smap.per(ptrans.form(new RPoint((u-pw)*TWO_PI,(v-ph)*PI)),4);
- RPoint p3=smap.per(ptrans.form(new RPoint((u+pw)*TWO_PI,(v-ph)*PI)),4);
- quad(p0.x+hw,p0.y+hh,p1.x+hw,p1.y+hh,p3.x+hw,p3.y+hh,p2.x+hw,p2.y+hh); //clockwise
- //quad(p0.x,p0.y,p1.x,p1.y,p3.x,p3.y,p2.x,p2.y); //clockwise
+
+ if (true) //draw globe 1 country per frame
+ {
+ if (false) { //draw countries
+ //noStroke();
+ //fill(fg);
+ println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths.length+" paths");
+
+ for (int l=0;l<calls.getcountry(i).outline.paths.length;l++) {
+ beginShape();
+ for (int k=0;k<calls.getcountry(i).outline.paths[l].commands.length;k++) {
+ RPoint sp=calls.getcountry(i).outline.paths[l].commands[k].startPoint;
+ RPoint dp=smap.per(ptrans.form(pnorm.alise(sp)),4);
+
+ vertex(dp.x+(getWidth()/2),dp.y+(getHeight()/2)); //,z); //z);
+ }
+ endShape();
+ }
+
+ }
+
+ if (false) { //draw centre lines from countries to ireland
+ RPoint Sp=ptrans.form(pnorm.alise(calls.countries.get(i).getcentre()));
+ RPoint Ep=ptrans.form(pnorm.alise(Ireland.getcentre()));
+ gstroke.drawstroke(Sp,Ep,fg);
+ }
+
+ if (false) { //draw great circle lines
+ for (int j=0;j<calls.countries.get(i).calls*.001;j++) {
+ RPoint s=calls.countries.get(i).getpoint();
+ RPoint e=Ireland.getpoint();
+ if (s.x>0&&e.x>0){ //point found
+ RPoint sp=ptrans.form(pnorm.alise(s));
+ RPoint ep=ptrans.form(pnorm.alise(e));
+ RPoint Sp=smap.per(sp,4);
+ RPoint Ep=smap.per(ep,4);
+ RPoint Mp=smap.per(GCircFract(sp,ep,0.8),4.1);
+ beginShape();
+ line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2));
+ line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2));
+ endShape();
+ }
}
- }
+ //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls");
+ }
+
+ if (true) { //draw gradient 3D lines
+ if (calls.countries.get(i).points.size()>0) {
+ for (int j=0;j<log10(calls.countries.get(i).calls)*50;j++) {
+ RPoint Sp=ptrans.form(pnorm.alise(calls.countries.get(i).getpoint()));
+ RPoint Ep=ptrans.form(pnorm.alise(Ireland.getpoint()));
+ //gstroke.drawstroke(Sp,Ep,fg);
+ RPoint Dp=smap.per(Sp,4);
+ ellipse(Dp.x+hw,Dp.y+hh,2,2);
+ }
+ }
+ }
}
- }
- //fill(fg);
-
- //pick a random colour
- //fg=color(random(150)+10,random(150)+10,random(150)+10);
- stroke(fg);
- //stroke(0,0,0,50);
-
-
- if (true) //draw globe 1 country per frame
- {
+ else //draw 2D
+ {
if (false) { //draw countries
- //noStroke();
- //fill(fg);
- println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths.length+" paths");
-
- for (int l=0;l<calls.getcountry(i).outline.paths.length;l++) {
beginShape();
- for (int k=0;k<calls.getcountry(i).outline.paths[l].commands.length;k++) {
- RPoint sp=calls.getcountry(i).outline.paths[l].commands[k].startPoint;
- RPoint dp=smap.per(ptrans.form(pnorm.alise(sp)),4);
+ for (int k=0;k<calls.getcountry(i).outline.paths[0].commands.length;k++) {
+ RPoint sp=calls.getcountry(i).outline.paths[0].commands[k].startPoint;
+ RPoint dp=screenMapper(pnorm.alise(sp));
- vertex(dp.x+(getWidth()/2),dp.y+(getHeight()/2)); //,z); //z);
+ vertex(dp.x,dp.y); //,z); //z);
}
endShape();
+ //println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths[0].commands.length+" points");
+ }
+ if (true) { //draw lines
+ for (int j=0;j<log10(calls.countries.get(i).calls)*1;j++) {
+ RPoint s=calls.countries.get(i).getpoint();
+ RPoint e=Ireland.getpoint();
+ if (s.x>0&&e.x>0){ //point found
+ RPoint Sp=screenMapper(pnorm.alise(s));
+ RPoint Ep=screenMapper(pnorm.alise(e));
+ RPoint Mp=plerp(Sp,Ep,0.75);
+ //beginShape();
+ //line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2));
+ //line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2));
+ //bezier(Sp.x, Sp.y, Sp.x, Sp.y-((getHeight()-Sp.y)*.1), Ep.x, Ep.y-((getHeight()-Ep.y)*.1), Ep.x, Ep.y);
+ //endShape();
+ bstroke.drawstroke(Sp,Ep);
+ }
}
-
- }
-
- if (false) { //draw centre lines from countries to ireland
- RPoint Sp=ptrans.form(pnorm.alise(calls.countries.get(i).getcentre()));
- RPoint Ep=ptrans.form(pnorm.alise(Ireland.getcentre()));
- gstroke.drawstroke(Sp,Ep,fg);
- }
-
- if (false) { //draw great circle lines
- for (int j=0;j<calls.countries.get(i).calls*.001;j++) {
- RPoint s=calls.countries.get(i).getpoint();
- RPoint e=Ireland.getpoint();
- if (s.x>0&&e.x>0){ //point found
- RPoint sp=ptrans.form(pnorm.alise(s));
- RPoint ep=ptrans.form(pnorm.alise(e));
- RPoint Sp=smap.per(sp,4);
- RPoint Ep=smap.per(ep,4);
- RPoint Mp=smap.per(GCircFract(sp,ep,0.8),4.1);
- beginShape();
- line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2));
- line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2));
- endShape();
+ //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls");
+ }
+ if (false) { //fill country
+ for (int j=0;j<calls.countries.get(i).points.size();j++) {
+ RPoint Sp=calls.countries.get(i).points.get(j).pt;
+ ellipse(Sp.x,Sp.y,1,1);
}
}
- //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls");
- }
-
- if (true) { //draw gradient 3D lines
- for (int j=0;j<log10(calls.countries.get(i).calls)*10;j++) {
- RPoint Sp=ptrans.form(pnorm.alise(calls.countries.get(i).getpoint()));
- RPoint Ep=ptrans.form(pnorm.alise(Ireland.getpoint()));
- gstroke.drawstroke(Sp,Ep,fg);
- }
- }
- }
- else //draw 2D
- {
- if (false) { //draw countries
- beginShape();
- for (int k=0;k<calls.getcountry(i).outline.paths[0].commands.length;k++) {
- RPoint sp=calls.getcountry(i).outline.paths[0].commands[k].startPoint;
- RPoint dp=screenMapper(pnorm.alise(sp));
-
- vertex(dp.x,dp.y); //,z); //z);
- }
- endShape();
- //println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths[0].commands.length+" points");
- }
- if (true) { //draw lines
- for (int j=0;j<log10(calls.countries.get(i).calls)*1;j++) {
- RPoint s=calls.countries.get(i).getpoint();
- RPoint e=Ireland.getpoint();
- if (s.x>0&&e.x>0){ //point found
- RPoint Sp=screenMapper(pnorm.alise(s));
- RPoint Ep=screenMapper(pnorm.alise(e));
- RPoint Mp=plerp(Sp,Ep,0.75);
- //beginShape();
- //line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2));
- //line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2));
- //bezier(Sp.x, Sp.y, Sp.x, Sp.y-((getHeight()-Sp.y)*.1), Ep.x, Ep.y-((getHeight()-Ep.y)*.1), Ep.x, Ep.y);
- //endShape();
- bstroke.drawstroke(Sp,Ep);
- }
- }
- //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls");
- }
- if (false) { //fill country
- for (int j=0;j<calls.countries.get(i).points.size();j++) {
- RPoint Sp=calls.countries.get(i).points.get(j).pt;
- ellipse(Sp.x,Sp.y,1,1);
- }
- }
- }
-
-
- i++;
-
- //}
- if (i==calls.countries.size()-1) {
- println("finished");
- noLoop();
- //save("160212_filled.png");
- if (mode=="PDF") exit();
+ }
+
+
+ i++;
+
+ //}
+ if (i==calls.countries.size()-1) {
+ println("finished");
+ noLoop();
+ if (mode=="PDF") exit();
+ else save("160212_test.png");
+ }
}
}