xxxxxxxxxx
var points = [];
var numPoints = 500;
function setup() {
createCanvas(windowWidth, windowHeight);
strokeWeight(0.3);
for(var n=0; n< numPoints; n++){
points.push(new PointInSpace());
}
}
function draw() {
background(0);
noFill();
points.map(function(p,i){
p.update();
stroke(255-p.vel,p.vel,0);
ellipse(p.x,p.y,10,10);
});
stroke(255,150);
beginShape();
vertex(points[0].x,points[0].y);
for(var n = 1; n < numPoints; n++){
var p = points[n];
quadraticVertex(p.x+p.vel-120,p.y+p.vel-120,p.x,p.y);
};
endShape(CLOSE)
}
function PointInSpace(x,y){
this.xOrigin = random(width);
this.yOrigin = random(height);
this.xOff = 0.0;
this.yOff = 0.0;
this.setup = function(){
this.xStep = random();
this.yStep = random();
this.vel = random(255);
this.x = this.xOrigin;
this.y = this.yOrigin;
}
this.update = function(){
this.xOff += this.xStep;
this.yOff += this.yStep;
var i = (noise(this.xOff)-.5)*this.vel/10 ;//* width ;
var j = (noise(this.yOff)-.5)*this.vel/10 ;//* height ;
// this.x = this.xOrigin + i;
// this.y = this.yOrigin + j;
this.x += i;
this.y += j;
if(this.x<0 || this.x>width) this.x = this.xOrigin;
if(this.y<0 || this.y>height) this.y = this.yOrigin;
}
this.setup();
return this;
}