xxxxxxxxxx
88
// noprotect
let _noise;
let cz = 0;
let maxZ;
let grid, sq_size, n_sq;
function setup() {
sq_size = 5;
n_sq = 100;
let freq = 0.1;
let octaves = 100;
offset = 50;
maxZ = 500;
_noise = new FastSimplexNoise({ frequency: freq, octaves: octaves });
grid = [];
cz = 0;
createCanvas(sq_size * n_sq, sq_size * n_sq);
colorMode(HSL);
angleMode(RADIANS);
let radius = 1;
for (let z = 0; z < maxZ; z++) {
grid[z] = [];
let t = (1.0*z)/maxZ;
for (let r = 0; r < n_sq; r++) {
grid[z][r] = [];
for (let c = 0; c < n_sq; c++) {
// let _n = _noise.get3DNoise(c, r, z);
let _n = _noise.get4DNoise(
c, r,
radius * cos(TWO_PI*t),
radius * sin(TWO_PI*t)
);
let _m = map(_n, -1.0, 1.0, 0, 360);
_c = color(_m,100,50);
grid[z][r][c] = { x: c * sq_size, y: r * sq_size, col: _c }; //color(random(255)) };
}
}
}
// grid = [];
// for (let z = 0; z < maxZ; z++) {
// let t = (1.0 * z) / maxZ;
// grid[z] = [];
// for (let y = 0; y < height; y++) {
// grid[z][y] = [];
// for (let x = 0; x < width; x++) {
// // grid[z][y][x] = _noise.get3DNoise(x, y, z);
// grid[z][y][x] = _noise.get4DNoise(
// x,
// y,
// // _scale*x,
// // _scale * y,
// radius * cos(TWO_PI * t),
// radius * sin(TWO_PI * t)
// );
// // boolean b = (float)noise.eval(scale*x,scale*y,radius*cos(TWO_PI*t),radius*sin(TWO_PI*t)) > 0;
// // float col = b?255:0;
// // pixels[x + width*y] = color(col);
// // }
// drawPoint(x, y, z, imgs[z]);
// }
// }
// }
}
function draw() {
background(220);
noStroke();
for (let r = 0; r < n_sq; r++) {
for (let c = 0; c < n_sq; c++) {
fill(grid[cz][r][c].col);
square(grid[cz][r][c].x, grid[cz][r][c].y, sq_size);
}
}
cz++;
if (cz > maxZ-1) noLoop();
// cz = 0;
}