> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.VBspqdLolIl/rev.299
 * 
 * authors: 
 *   John W

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



/*
This sketch builds on a prior work, "Collatz Conjecture Viz", created by John W
http://studio.sketchpad.cc/sp/pad/view/ro.9$A0PEqdFBdj4/rev.2155
*/




/*
This sketch builds on a prior work, "Untitled Sketch", created by [unnamed author]
http://sketchpad.cc/sp/pad/view/ro.v$1kuiTesaE/rev.628
*/


PVector[] dotArray = new PVector[200000];
float curX = 0; 
float curY = 0; 
int curZ = 0; 
orgVal = 0;

float rot = 0.0; 

int dPC = 1;  //dots per column
int wPad = 10; //horizontal padding between cols

int currentVal = 2; 
int prevVal = 10;

int currentCol = 1; 
int currentDot = 0;

int colCount = 1;

int hue1 = 0; 




void setup() {
       size(1480,800, P3D);
       curX = wPad * dPC; 
        colorMode(HSB,360,100,100);
       
           
    
    for(k = 0; k < dotArray.length(); k++){
    
        curY = height *2 / (dPC +1);
        for(j = 0; j < dPC ; j++) {
   
            dotArray[k] = new PVector(curX,curY ,0);
         
        
        curY += height *2/( dPC + 1);
        k++;
            }
            colCount++
            dPC ++; 
            curX = wPad * dPC; 
            curY = height *2/( dPC + 1);
            k--;
        }    
    }

void draw() {
   
         smooth(3);
    translate(-800,-height/2,-1000);  
     if(frameCount == 1){
        background(40,80,100);
        }
  //  for(k = 0; k < dotArray.length(); k++){
   //   noStroke();
   //   fill(100);
   //  rect(dotArray[k].x, dotArray[k].y, 3,3); 
  //     }    
        
        if( currentVal == 1){
    
    currentVal = int(random( 0, 10000));
    prevVal =0;
    orgVal = currentVal;
    currentCol = 1;
    currentDot = 0; 
    curZ = 0;
   
    
   //  pushMatrix(); 
   // rotateY((rot));
 
    } else if (currentVal % 2 == 0){
    prevVal = currentVal;
    currentVal /= 2;
    //stroke(0,154,204,map(orgVal, 0, 200000000, 0 , 100));
    hue1 = map(currentVal, 0, 10000, 10, 360);
    stroke(hue1, 50,50);
    line(dotArray[currentDot].x, dotArray[currentDot].y, 0, dotArray[currentDot + currentCol].x, dotArray[currentDot + currentCol].y,0); 
    
    currentDot += currentCol;
    currentCol ++;
    curZ ++; 
 
    
    if (currentCol >= 300){
        prevVal = 1; 
        currentVal =1 ;
        curZ = 0;
        orgVal = currentval;
        }
    
    
    }else{
        prevVal = currentVal;
        currentVal = (currentVal * 3) + 1;
    //  stroke(224,5,5,map(orgVal, 0, 200000000, 0 , 100));
        stroke(hue1, 50,50);
        line(dotArray[currentDot].x, dotArray[currentDot].y, 0, dotArray[currentDot + currentCol + 1].x, dotArray[currentDot + currentCol + 1].y,0); 
        
        currentDot += currentCol + 1;
        currentCol ++;
        curZ --; 
        
         if (currentCol >= 300){
        prevVal = 1;
        currentVal =1 ;
        curZ = 0 
        }
        }
      //     popMatrix();
   
    
    
    }