Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float a, b, c, d, x, y, xp, yp;
- PFont f;
- int hit[][] = new int[800][800]; //set size of hit detection, should be equal to window size
- void setup() {
- size(800, 800); //window size
- f = createFont("Arial", 16, true);
- a = -4.2; //parameters
- b = -0.5;
- c = -1;
- d = -2.2;
- }
- void draw() {
- makeFlame();
- }
- void makeFlame() {
- background(0);
- for (int i = 0; i < 800; i++) {
- for (int o = 0; o < 800; o++) {
- hit[i][o] = 0; //reset array
- }
- }
- xp = -2;
- yp = -2;
- for (int i = 0; i < 1000000; i++) { //iterations
- x = sin(yp * b) - c * sin(xp * b);
- y = sin(xp * a) + d * sin(yp * a);
- 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
- xp = x;
- yp = y;
- }
- int max = 0;
- for (int i = 0; i < 800; i++) {
- for (int o = 0; o < 800; o++) {
- max = max(hit[i][o], max);
- }
- }
- for (int i = 0; i < 800; i++) {
- for (int o = 0; o < 800; o++) {
- if (hit[i][o] > 0) {set(i, o, color(constrain(log(float(hit[i][o])) * 100, 0, 255)));} //logarithmic color scale
- //if (hit[i][o] > 0) {set(i, o, color(255));} //hit or not hit color scale
- }
- }
- fill(255, 0, 0);
- noStroke();
- textFont(f, 20);
- text("a = " + str(a) + "\nb = " + str(b) + "\nc = " + str(c) + "\nd = " + str(d), 10, 30); //draw text
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement