From 5a68500983aba528b0add0d2bc22abfc092c508a Mon Sep 17 00:00:00 2001 From: "git@eclectronics.org" Date: Thu, 16 Feb 2012 16:46:43 +0000 Subject: drawing 3d calpaths --- bezierstroke.pde | 166 ++++++++++++++++++++++++++++++++++++++ data/countries_named_mercator.svg | 10 +-- parsecalldata.pde | 7 +- vodaviz.pde | 109 +++++++++++++++++++------ 4 files changed, 260 insertions(+), 32 deletions(-) diff --git a/bezierstroke.pde b/bezierstroke.pde index 2cb85de..5070f9b 100644 --- a/bezierstroke.pde +++ b/bezierstroke.pde @@ -26,3 +26,169 @@ class bezierstroke { endShape(); } } +RPoint perpoint(RPoint p1,RPoint p2,float d) { + //returns a point left distance d of perpendicular line between points + float h=atan2(p2.y-p1.y,p2.x-p1.x); + return new RPoint(p2.x+(cos(h+HALF_PI)*d),p2.y+(sin(h+HALF_PI)*d)); +} + +class gradientstroke { + float startsize,endsize,mpfract,raisefract,bezierfract; + float[] transpos; + float[] transamt; + color col; + gradientstroke(float _s,float _e,float[] _p, float[] _a,color _c){ + startsize=_s; + endsize=_e; + transpos=_p; + transamt=_a; + col=_c; + } + void drawstroke(RPoint Sp,RPoint Ep) { + drawstroke(Sp,Ep,col); + } + void drawstroke(RPoint Sp,RPoint Ep,color _col) { + noStroke(); + fill(red(_col),green(_col),blue(_col),255); + + //put ellipses in a seperate layer + //ellipse(Sp.x,Sp.y,startsize,startsize); + //ellipse(Ep.x,Ep.y,endsize,endsize); + + //construct quads along path + //path is straight, curve comes from 3D/ raise + //how to deal with badly formatted control arrays? bother? + //3d stage in between + noFill(); + + float spos=0.0; + float step=.001; //optimise + + //quad corner points + //these are perpedicular on the screen as we are making a gradient line system + RPoint L0,L1,p0,p1,p2,p3; + p0=new RPoint(0,0); + p1=p0; + L0=Sp; + boolean notfirst=false; + for (int i=0;i