Skip to content

Instantly share code, notes, and snippets.

@tttardigrado
Last active June 27, 2023 17:56
Show Gist options
  • Save tttardigrado/669b3ca11eddc09dbc871e958a7cdd4f to your computer and use it in GitHub Desktop.
Save tttardigrado/669b3ca11eddc09dbc871e958a7cdd4f to your computer and use it in GitHub Desktop.
Slightly altered version of Clifford attractors.

CLIFFORD

Slightly altered (blured) version of Clifford attractors.

It follows the standard equations:

$$ x_{n+1} = \sin(a \cdot y_n) + c \cdot \cos(a \cdot x_n) $$

$$ y_{n+1} = \sin(b \cdot x_n) + d \cdot \cos(b \cdot y_n) $$

but after a given number of iterations one of the parameters (in this case $a$) is slightly incremented.

For more information on standard Clifford attarctors, check this post.

const SIZE = 1000; // width/height of the canvas
const SCALE = SIZE / 4.4; // scaling factor to draw points
const ITER = 10000; // iterations / frame
const INC = 0.001; // increment of a every frame
// Clifford attractor parameters
let a = 1.48;
let b = 1.6;
let c = 1;
let d = 0.78;
// Start (x, y) position
let x = 0;
let y = 0;
function setup(){
createCanvas(SIZE, SIZE);
background(200);
stroke(0, 0, 0, 20);
}
function draw(){
translate(SIZE/2, SIZE/2);
// draw and update (x, y) an ITER number of times
// just used to make results visible faster
for (let i = 0; i < ITER; i++) {
// draw
point(SCALE*x, SCALE*y);
// update
let x1 = sin(a*y) + c*cos(a*x);
let y1 = sin(b*x) + d*cos(b*y);
x = x1;
y = y1;
}
// update a's value
a += 0.001
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment