summaryrefslogtreecommitdiff
path: root/vodaviz.pde
diff options
context:
space:
mode:
Diffstat (limited to 'vodaviz.pde')
-rw-r--r--vodaviz.pde109
1 files changed, 84 insertions, 25 deletions
diff --git a/vodaviz.pde b/vodaviz.pde
index d12db59..3f104a0 100644
--- a/vodaviz.pde
+++ b/vodaviz.pde
@@ -78,6 +78,17 @@ The intermediate latitude and longitude is then given by:
drawing - circles (fixed diameter), closed shape made of 2 bezier curves
+paths above 3d globe
+fix missing countries
+render above map
+colours
+sort lines according to destination ?
+
+match 3D map or render texture out of processing
+or export 3d lines - dx
+
+cache points!
+
*/
import processing.pdf.*;
@@ -108,7 +119,7 @@ class pointTransform {
RPoint form(RPoint in) {
//transform
- return new RPoint (((in.x*0.25)+(PI/2)),((in.y)*0.3)+(PI/2)); //front half of sphere
+ return new RPoint (((in.x*0.053)+(PI/2)-.01),((in.y)*0.14)+(PI/2)-.1); //front half of sphere
}
}
@@ -120,9 +131,9 @@ class sphereMap {
//map to 3D sphere
float r=getHeight()*_r;
- float x=r*cos(p.x)*(sin(p.y)) *2;
- float z=r*sin(p.x)*(sin(p.y))-985;
- float y=r*cos(p.y)+(getHeight()*0.5)-210;
+ float x=r*cos(p.x)*(sin(p.y)) *4;
+ float z=r*sin(p.x)*(sin(p.y)) -985;
+ float y=r*cos(p.y)+(getHeight()*1)-330;
//camera at 0,0,0
//screen plane at 0,0,100
@@ -173,6 +184,7 @@ calldata calls;
bitmapcountry Ireland;
bezierstroke bstroke;
+gradientstroke3D gstroke;
PImage lightmap;
color bg,fg;
@@ -182,12 +194,12 @@ void setup(){
RG.init(this);
//mode="PDF";
- if (mode=="PDF") size(832,220,PDF, "vodaviz_test_140212.pdf"); //P3D); //832,220); //nb pdf is 800x600
+ if (mode=="PDF") size(832,220,PDF, "vodaviz_bg_160212.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
bg=color(164,215,244);
- fg=color(255,255,255);
+ fg=color(#D2131D);
smooth();
float m = millis();
@@ -198,7 +210,7 @@ void setup(){
ptrans = new pointTransform();
smap = new sphereMap();
- lightmap=loadImage("earth_lights.gif");
+ lightmap=loadImage("vodaviz_bg_160212.png");
float startsize=0.2;
float endsize=0.1;
@@ -208,6 +220,13 @@ void setup(){
float bezierfract=0.25;
bstroke = new bezierstroke(startsize,endsize,linewidth,mpfract,raisefract,bezierfract);
+ startsize=10;
+ endsize=.5;
+ float[] transpos={0.0,0.15,0.85,1.0};
+ float[] transamt={0.5,0.2,0.2,0.5};
+ color col=color(0,0,0);
+ gstroke=new gradientstroke3D(startsize,endsize,transpos,transamt,col,smap);
+
RG.ignoreStyles();
println("loaded svg in "+((millis()-m)*.001)+" seconds");
Ireland=new bitmapcountry("Ireland",0,0,shp.children[0]);
@@ -218,7 +237,7 @@ void setup(){
background(255,255,255);
noFill();
stroke(255);
- strokeWeight(.02);
+ strokeWeight(.002);
if (false) { //check worked example http://williams.best.vwh.net/avform.htm#Example
RPoint LAX=new RPoint(2.066470,0.592539);
@@ -238,35 +257,68 @@ int j=0;
void draw() {
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);
+ 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);
+ //fill(fg);
//pick a random colour
- //stroke(random(150)+10,random(150)+10,random(150)+10);
+ //fg=color(random(150)+10,random(150)+10,random(150)+10);
+ stroke(fg);
//stroke(0,0,0,50);
- if (false) //draw globe
+ if (true) //draw globe 1 country per frame
{
- if (true) { //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=smap.per(ptrans.form(pnorm.alise(sp)),4);
-
- vertex(dp.x+(getWidth()/2),dp.y+(getHeight()/2)); //,z); //z);
- }
- endShape();
- //println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths[0].commands.length+" points");
+ 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 (true) { //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 (true) {
+ if (false) {
for (int j=0;j<calls.countries.get(i).calls*.001;j++) {
RPoint s=calls.countries.get(i).getpoint();
RPoint e=Ireland.getpoint();
@@ -317,6 +369,12 @@ void draw() {
}
//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);
+ }
+ }
}
@@ -326,6 +384,7 @@ void draw() {
if (i==calls.countries.size()-1) {
println("finished");
noLoop();
+ //save("160212_filled.png");
if (mode=="PDF") exit();
}
}