Example #1
0
  /* initialize pattern bezier elements with random values */
  public void randomizeElements(float f, float r, boolean all) {

    for (int p = 0; p < pNumMax; p++) {
      if (activated[p] || all) {
        if (all || !animationQueue || (animationQueue && p == theActive[animationQueuePointer])) {
          //					post("p "+p+"   animationQueue "+animationQueue+"  animationQueuePointer
          // "+animationQueuePointer+
          //							"   theActive[animationQueuePointer]) "+theActive[animationQueuePointer]);
          for (int e = 0; e < eNumMax; e++) {

            // randomize bezier point noise
            for (int b = 0; b < bNum; b++) {
              // set noise to 0 if element is not active (<eNum)
              if (dice(f))
                patternNoise[p][e][b][0] = (e < eNum) ? (float) Math.random() * 2 - 1.f : 0.f;
              else if (dice(r)) patternNoise[p][e][b][0] = 0.f;
              if (dice(f))
                patternNoise[p][e][b][1] = (e < eNum) ? (float) Math.random() * 2 - 1.f : 0.f;
              else if (dice(r)) patternNoise[p][e][b][1] = 0.f;
              if (dice(f)) patternNoise[p][e][b][2] = 0.f;
              else if (dice(r)) patternNoise[p][e][b][2] = 0.f;
            }
          }
        }
      }
    }
  }
Example #2
0
 public void randomizeWidth(float f, float r, boolean all) {
   for (int p = 0; p < pNumMax; p++) {
     if (activated[p] || all) {
       if (all || !animationQueue || (animationQueue && p == theActive[animationQueuePointer])) {
         for (int e = 0; e < eNumMax; e++) {
           // randomize width noise
           if (dice(f)) widthNoise[p][e] = (float) Math.random() * 2 - 1.f;
           else if (dice(r)) widthNoise[p][e] = 0.f;
         }
       }
     }
   }
 }
Example #3
0
  /* chance function. return true if random value within threshold */
  private boolean dice(double f) {

    double v = Math.random();
    if (v < f) return true;
    else return false;
  }