G2A Many GEOs
SHARE
TWEET

Processing script for king dream fractal

a guest Aug 4th, 2018 93 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. PFont f;
  3. int hit[][] = new int[800][800]; //set size of hit detection, should be equal to window size
  4.  
  5. void setup() {
  6.   size(800, 800); //window size
  7.   f = createFont("Arial", 16, true);
  8.   a = -4.2; //parameters
  9.   b = -0.5;
  10.   c = -1;
  11.   d = -2.2;
  12. }
  13.  
  14. void draw() {
  15.   makeFlame();
  16. }
  17.  
  18. void makeFlame() {
  19.   background(0);
  20.   for (int i = 0; i < 800; i++) {
  21.     for (int o = 0; o < 800; o++) {
  22.       hit[i][o] = 0; //reset array
  23.     }
  24.   }
  25.   xp = -2;
  26.   yp = -2;  
  27.   for (int i = 0; i < 1000000; i++) { //iterations
  28.     x = sin(yp * b) - c * sin(xp * b);
  29.     y = sin(xp * a) + d * sin(yp * a);  
  30.     if (i > 100) {hit[int(constrain(map(x, -5, 5, 0, 800), 0, 800))][int(constrain(map(y, -5, 5, 0, 800), 0, 800))] += 1;} //discard first 100 points
  31.     xp = x;
  32.     yp = y;
  33.   }  
  34.   int max = 0;
  35.   for (int i = 0; i < 800; i++) {
  36.     for (int o = 0; o < 800; o++) {
  37.       max = max(hit[i][o], max);
  38.     }
  39.   }
  40.   for (int i = 0; i < 800; i++) {
  41.     for (int o = 0; o < 800; o++) {
  42.       if (hit[i][o] > 0) {set(i, o, color(constrain(log(float(hit[i][o])) * 100, 0, 255)));} //logarithmic color scale
  43.       //if (hit[i][o] > 0) {set(i, o, color(255));} //hit or not hit color scale
  44.     }
  45.   }
  46.   fill(255, 0, 0);
  47.   noStroke();
  48.   textFont(f, 20);
  49.   text("a = " + str(a) + "\nb = " + str(b) + "\nc = " + str(c) + "\nd = " + str(d), 10, 30); //draw text
  50. }
RAW Paste Data
Ledger Nano X - The secure hardware wallet
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