Skip to content
Please note that GitHub no longer supports Internet Explorer.

We recommend upgrading to the latest Microsoft Edge, Google Chrome, or Firefox.

Learn more

Instantly share code, notes, and snippets.

@jn3008 jn3008/donut_noise.pde
Last active Jan 9, 2020

Embed
What would you like to do?
//by Jo
//https://twitter.com/jn3008/status/1169671889121435656
// opensimplexnoise code in another tab is necessary
// --> code here : https://gist.github.com/Bleuje/fce86ef35b66c4a2b6a469b27163591e
void setup() {
size(800, 600, P2D);
smooth(8);
noFill();
strokeWeight(2);
stroke(255);
noise = new OpenSimplexNoise();
}
OpenSimplexNoise noise;
float t, radius = 300, noise_radius = 1.8;
int nj = 24, ni = 120;
void draw() {
t += 0.005;
t%=1;
translate(width*0.5, height* 0.5);
background(0);
for (int j = 0; j <= nj; j++) {
for (int i = 0; i < ni; i++) {
float th = TAU*i/ni;
PVector posShape = new PVector(map(j, 0, nj, 1, 0.3), 0).rotate(th);
float ph = TAU*(i*1.0/ni+j*0.5/nj+t);
//position in noise planes, on the surface of a torus
PVector posNoise = new PVector(noise_radius*(1+cos(ph)), 0, noise_radius*sin(ph)).rotate(th);
posShape.mult(radius*0.8 + radius*0.15*(float)noise.eval(posNoise.x, posNoise.y, posNoise.z, 0.8*sin(posNoise.heading())));
point(posShape.x, posShape.y);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.