xxxxxxxxxx
87
let width = 400;
let height = 400;
let sprites = [];
let rows,cols;
let size = 100;
function setup() {
createCanvas(width , height,WEBGL);
angleMode(DEGREES);
rows = width/size;
cols = height/size;
polarGrid();
}
function draw(){
background(255);
// translate(-width * 0.5,-height * 0.5);
for(let i=0; i < sprites.length; i++){
sprites[i].display();
sprites[i].update();
}
}
function polarGrid(){
let xstart = cos(random(10)) * 100;
let xnoise = xstart;
let ynoise = random(10);
let _inc = 0.1;
for(let i=0; i<=180; i+=size * 0.025){
let posx = cos(i) * size;
let posy = sin(i) * size;
let negx = cos(-i) * size;
let negy = sin(-i) * size;
let p1 = createVector(posx, posy);
let p2 = createVector(negx, negy);
let d = p2.dist(p1);
let _step = d * 0.045;
ynoise += _inc;
xnoise = xstart;
for(let j=0; j<d; j+=_step){
let _x = posx + cos(-90) * j;
let _y = posy + sin(-90) * j;
xnoise += _inc;
let perlin = noise(xnoise, ynoise);
let angle = perlin * 360;
let spd = 5;
let sprite = new Sprite(_x,_y,_step,angle,spd);
sprites.push(sprite);
}
}
}