1. //neighbors_140831b

     
  2. //neighbors_140831a

     
  3. //neighbors_140830a
    ArrayList<PointPosition> pointPosition = new ArrayList();
    boolean alternate = false;
    int threshold = 200;
    int width = 500,
        height = 750,
        dx = 0,
        dy = 0;
    int[] directions = {
        1,
        -1,
        width,
        -width,
        (width*-1)-1,
        (width*-1)+1,
        width+1,
        width-1
      };
    int[] pDirections = {
        1,
        -1
      };

    void setup(){
      size(width,height);
      background(0);
      frameRate(24);
      seedPoints(width);
    }

    void draw(){
      scale(5);
      translate(-100,-100);
      for(PointPosition p:pointPosition){
        dx = pDirections[int(random(pDirections.length))];
        dy = pDirections[int(random(pDirections.length))];
        p.update(dx,dy);
        p.render();
      }
      loadPixels();
        for (int k=width+1; k<width*height-width-1; k++){
          int neighbors = 0;
          int pModifier = directions[int(random(directions.length))];
          for (int i=0; i<directions.length; i++) {
            if (brightness(pixels[k+directions[i]]) > threshold) {
              neighbors++;
            } else if (pModifier == directions[i]) {
              pModifier = directions[int(random(directions.length))];
            }
          }
          switch(neighbors) {
            case 0:
              if (brightness(pixels[k]) > threshold) {
                //pixels[k] = color(255);
                pixels[k] = color(
                    map(k,0,abs(cos(k)*k),0,255),
                    map(cos(k),0,1,0,255),
                    map(sin(k),0,1,0,255)
                  );
              }
              break;
            case 1:
              if (brightness(pixels[k]) > threshold) {
                pixels[k] = color(0);
              }
              break;
            case 2:
              pixels[k] = pixels[k+pModifier];
              break;
            case 3:
              if (brightness(pixels[k]) > threshold) {
                pixels[k] = pixels[k+pModifier];
              }
              break;
            default:
              pixels[k] = color(0);
              break;
          }
        }
      updatePixels();
      threshold = setThreshold(threshold,50,225);
    }

    class PointPosition {
      float x,y;
      color c;
      void update(int dx, int dy){
        x += dx;
        y += dy;
      }
      void render(){
        stroke(c);
        point(x,y);
      }
    }

    int setThreshold(int threshold, int minThreshold, int maxThreshold) {
      if (threshold <= maxThreshold && threshold >= minThreshold && alternate) {
        threshold++;
      } else if (threshold <= maxThreshold && threshold >= minThreshold) {
        threshold—;
      } else if (alternate) {
        threshold = maxThreshold;
        alternate = !alternate;
      } else {
        threshold = minThreshold;
        alternate = !alternate;
      }
      return threshold;
    }

    void seedPoints(int count){
      for (int i=0; i<count; i++) {
        PointPosition p = new PointPosition();
          p.c = color(
                  map(i,0,abs(cos(i)*count),153,255),
                  map(i,0,abs(sin(i)*count),0,255),
                  map(sin(i),0,1,135,255)
                  );
          p.x = width/2+int(sin(i)*width/3);//width/2+int(cos(i)*width/(i/int(count/10)));
          p.y = width/2+int(cos(i)*i);
        pointPosition.add(p);
      }
    }

    void mousePressed(){
      record = !record;
    }

     
  4. //dispersedStrata_140829b

     
  5. //dispersedStrata_140829a

     
  6. //dispersedStrata_140826b

     
  7. //dispersedStrata_140825b

     
  8. //dispersedStrata_140826a

     
  9. //dispersedStrata_140825a
    ArrayList<PointPosition> pointPosition = new ArrayList();
    boolean alternate = false;
    int threshold = 135;
    int width = 500,
        height = 750,
        dx = 0,
        dy = 0;
    int[] directions = {
        (width*-1)-1,
        (width*-1)+1,
        width+1,
        width-1
      };
    int[] pDirections = {
        1,
        -1
      };

    void setup(){
      size(width,height);
      background(0);
      frameRate(24);
      seedPoints(width);
    }

    void draw(){
      fill(50,5);
      rect(-2,-2,width+2,height+2);
      for(PointPosition p:pointPosition){
        dx = pDirections[int(random(pDirections.length))];
        dy = pDirections[int(random(pDirections.length))];
        p.update(dx,dy);
        p.render();
      }
      loadPixels();
        for (int k=width+1; k<width*height-width-1; k++){
          int pModifier = directions[int(random(directions.length))];
          if (brightness(pixels[k]) == threshold) {
            pixels[k-1] = pixels[k+1];
          } else if (brightness(pixels[k]) < threshold){
            //
          } else {
            pixels[k-width] = pixels[k];
            pixels[k] = pixels[k+pModifier];
          }
        }
      updatePixels();
      threshold = setThreshold(threshold,0,255);
    }

    class PointPosition {
      int x,y;
      color c;
      void update(int dx, int dy){  
        x = x + dx;
        y = y + dy;
      }
      void render(){
        stroke(c);
        point(x,y);
      }
    }

    int setThreshold(int threshold, int minThreshold, int maxThreshold) {
      if (threshold <= maxThreshold && threshold >= minThreshold && alternate) {
        threshold++;
      } else if (threshold <= maxThreshold && threshold >= minThreshold) {
        threshold—;
      } else if (alternate) {
        threshold = maxThreshold;
        alternate = !alternate;
      } else {
        threshold = minThreshold;
        alternate = !alternate;
      }
      return threshold;
    }

    void seedPoints(int count){
      for (int i=0; i<count; i++) {
        PointPosition p = new PointPosition();
          p.c = color(
                  map(i,0,abs(cos(i)*count),0,255),
                  map(i,0,abs(sin(i)*count),0,255),
                  map(sin(i),0,1,0,255)
                  );
          p.x = width/2+int(sin(i)*width/3);
          p.y = height/2+int(tan(i)*i);
        pointPosition.add(p);
      }
    }

     
  10. //protein_140825a