Feb 07

Processing – DeJong Fractal

Filed under: Playground | Taged as: | Comments Off

My first experiment with processing, an open source programming languages designed for coding visual images, animation and interactions.

Target was coding a DeJong fractal, based on the formular:

xn+1 = sin(a yn) - cos(b xn)
yn+1 = sin(c xn) - cos(d yn)

The code for drawing is quite short:

int p = 100;
int speed = 100;
float a = 2.01, b = -2.53, c = 1.61, d = -0.33;
float xn, yn;
float x = 0, y = 0;
int al = 100;
int maxcount = 100, count = 0;

void setup() {

size(400, 300);
background(255);
framerate(15);

}

void draw() {

if(count++ > maxcount) noLoop();

color col = color(10, al);

for(int i = 0; i < speed; i++){

xn = sin(a * y) - cos(b * x);
yn = sin(c * x) - cos(d * y);

x = xn;
y = yn;

set(round(x * p) + 200, round(y * p) + 240, col);
}

}

Chek out the DeJong fractal or download the Processing DeJong fractal

Comments are closed.