drandrewthomas_codesnippets/processingjs/pjsgrafdrawpde.txt
/************************************/
/* Graffiti GML drawing program for */
/* processing.js on HTML5 canvases. */
/* Andrew Thomas, October 2010.     */
/* Graffiti tag by @hellocatfood.   */
/************************************/

/*************************************************/
/* This program is free software: you can        */
/* redistribute it and/or modify it under the    */
/* terms of the GNU General Public License       */
/* as published by the Free Software Foundation, */
/* either version 3 of the License, or (at your  */
/* option) any later version.                    */
/*                                               */
/* This program is distributed in the hope that  */
/* it will be useful, but WITHOUT ANY            */
/* WARRANTY; without even the implied            */
/* warranty of MERCHANTABILITY or FITNESS        */
/* FOR A PARTICULAR PURPOSE.  See the            */
/* GNU General Public License for more details.  */
/*                                               */
/* See http://www.gnu.org/licenses/ for full     */
/* details of licenses.                          */
/*************************************************/

float x[]={0.5272365,0.53458613,0.5467151,0.56003696,0.5707171,0.58955777,0.6192574,0.6516739,0.6671278,0.64452946,0.5815496,0.5393447,0.5332032,0.5889989,0.66615874,0.7030894,0.66528,0.5602778,0.4223058,0.29079157,0.2241011,0.2412408,0.29697457,0.33883882,0.3537149,0.35890448,0.34256256,0.28408545,0.18861553,0.08242604,0.05,0.16978422,0.402592,0.6710077,0.8292523,0.92467517,0.95,0.8828315,0.710217,999999.0};
float y[]={0.7326609,0.74278474,0.775683,0.8176512,0.8585095,0.84172994,0.6856955,0.41386297,0.1771918,0.05728625,0.13191085,0.36652187,0.6141331,0.69628155,0.6999441,0.6671193,0.57455766,0.43668917,0.2638795,0.14307128,0.0757502,0.106160656,0.3229642,0.67073,0.95,0.9455859,0.65429604,0.3891407,0.39371026,0.4893341,0.37826967,0.10755572,0.05,0.10309413,0.27496222,0.46639565,0.5716164,0.65865827,0.751276,999999.0};
float z[]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,999999.0};
float t[]={0.0,0.122,0.237,0.294,0.362,0.455,0.53,0.606,0.684,0.779,0.842,0.931,1.022,1.092,1.19,1.252,1.336,1.41,1.497,1.564,1.644,1.738,1.825,1.898,1.964,2.046,2.139,2.222,2.292,2.378,2.454,2.699,2.773,2.859,2.937,3.013,3.101,3.209,3.267,999999.0};

int[] swidth=new int[t.length];
int[] salpha=new int[t.length];

int numpoints=x.length;
int stime,r,g,b,br,bg,bb,c=1;
float tmin=999999;
float tmax=-999999;

void setup()
{
  stime=millis();
  r=int(random(255));
  g=int(random(255));
  b=int(random(255));
  br=int(random(255));
  bg=int(random(255));
  bb=int(random(255));
  for(int c=1;c<numpoints;c++)
  {
    if(x[c-1]!=999999 && x[c]!=999999)
    {
      if((t[c]-t[c-1])<tmin) tmin=t[c]-t[c-1];
      if((t[c]-t[c-1])>tmax) tmax=t[c]-t[c-1];
    }
  }
  for(int c=0;c<numpoints;c++)
  {
    if(x[c]!=999999)
    {
      x[c]=height-x[c]*height;
      y[c]=y[c]*width;
    }
    if(x[c]!=999999 && c>0)
    {
      swidth[c]=int(map(t[c]-t[c-1],tmin,tmax,20,5));
      salpha[c]=int(map(t[c]-t[c-1],tmin,tmax,255,50));
      if(swidth[c]>10) swidth[c]=10;
    }
  }
  background(br,bg,bb);
}

void draw()
{
  if(x[c]==999999 && c<(numpoints-1)) c++;
  else
  {
    if(((t[c]*1000)<(millis()-stime)) && c<numpoints)
    {
      if(x[c-1]!=999999 && x[c]!=999999)
      {
        strokeWeight(swidth[c]);
        stroke(r,g,b,salpha[c]);
        line(y[c-1],x[c-1],y[c],x[c]);
      }
      c++;
    }
  }
}

void mouseReleased()
{
  c=1;
  stime=millis();
  r=int(random(255));
  g=int(random(255));
  b=int(random(255));
  br=int(random(255));
  bg=int(random(255));
  bb=int(random(255));
  background(br,bg,bb);
}

