SHARE
TWEET

Untitled

a guest Aug 5th, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float a, b, c, d, x, y, xp, yp;
  2. int x_, y_;
  3. PFont f;
  4.  
  5. int i = 0;
  6. int imax = 10000; //number of steps to take
  7.  
  8. int hit[][] = new int[1500][1000];
  9.  
  10. void setup() {
  11.   size(1500, 1000, P3D);
  12.   f = createFont("Arial", 16, true);
  13.   a = 0.59;
  14.   b = -3;
  15.   c = -1.4;
  16.   d = 1.2;
  17.   xp = random(-2, 2);
  18.   yp = random(-2, 2);
  19.   background(0);
  20.   fill(255, 0, 0);
  21.   noStroke();
  22.   textFont(f, 20);
  23.   text("a = " + str(a) + "\nb = " + str(b) + "\nc = " + str(c) + "\nd = " + str(d), 10, 30);
  24.  
  25.   for (int j = 0; j < 1500; j++) {
  26.     for (int k = 0; k < 1000; k++) {
  27.       hit[j][k] = 0;
  28.     }
  29.   }
  30. }
  31.  
  32. void draw() {
  33.   //background(0);
  34.   if (i < imax) {
  35.   xp = random(-2,2);
  36.   yp = random(-2,2);
  37.   b = map(i, 0, imax, -3, -2); //set your interval here
  38.   for (int j = 0; j < 50000; j++) { //set nuber of iterations
  39.     x = sin(yp * b) - c * sin(xp * b);
  40.     y = sin(xp * a) + d * sin(yp * a);
  41.     xp = x;
  42.     yp = y;
  43.     x_ = int(map(i, 0, imax, 0, width));
  44.     y_ = int(map(y, -1, 1, 1000, 0)); //set bound of y
  45.     if (j > 5000 && x_ >= 0 && x_ < 1500 && y_ >= 0 && y_ < 1000) { //set number of omitted iterations
  46.       hit[x_][y_] += 1;
  47.       set(x_, y_, color(255));
  48.     }
  49.   }
  50.   println(str(float(i)/imax * 100) + "% done");
  51.   i++;
  52.   } else {
  53.     background(0);
  54.     int max = 0;
  55.     for (int j = 0; j < 1500; j++) {
  56.       for (int k = 0; k < 1000; k++) {
  57.         max = max(max, hit[j][k]);
  58.       }
  59.     }
  60.     for (int j = 0; j < 1500; j++) {
  61.       for (int k = 0; k < 1000; k++) {
  62.         if (hit[j][k] > 0) {set(j, k, color(map(log(float(hit[j][k])), 0, log(max), 0, 255)));}
  63.       }
  64.     }
  65.   fill(255, 0, 0);
  66.   noStroke();
  67.   textFont(f, 20);
  68.   text("a = " + str(a) + "\nb = " + str(b) + "\nc = " + str(c) + "\nd = " + str(d), 10, 30);
  69.   }
  70. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top