constructor(c, p, d, a) {
ellipse(this.position.x, this.position.y, this.SIZE, this.SIZE);
let newPosition = this.position.copy().add(this.direction);
if (newPosition.x + this.SIZE * 2 < 0 || newPosition.x - this.SIZE * 2 > width) {
this.direction.x = -this.direction.x;
if (newPosition.y + this.SIZE * 2 < 0 || newPosition.y - this.SIZE * 2 > height) {
this.direction.y = -this.direction.y;
this.position.add(this.direction);
this.direction.add(this.acceleration);
this.acceleration.mult(0.9);
for (let i = 0; i < n; i++) {
let position = createVector(random(0, width), random(0, height));
let direction = randomVector(-2.5, 2.5);
let acc = randomVector(-0.5, 0.5);
let nullVector = createVector(0, 0);
this.population.push(new Fellow(color('lightpink'), position, direction, nullVector));
this.population.push(new Fellow(color('deepskyblue'), position, direction, nullVector));
for (let i = 0; i < this.population.length - 1; i++) {
for (let j = i + 1; j < this.population.length; j++) {
let v1 = this.population[i].getPosition();
let v2 = this.population[j].getPosition();
let thisDist = distSq(v1, v2);
if (thisDist < this.distance) {
let heading = p5.Vector.sub(v2, v1);
let heading2 = p5.Vector.sub(v1, v2);
let smallStep = heading.div(2*lineLerp);
let smallStep2 = heading2.div(2*lineLerp);
let weight = map(distSq(v1, v2), 0, this.distance, maxLine, 0);
let h = hue(this.population[i].c);
let s = saturation(this.population[i].c);
let b = brightness(this.population[i].c);
let c = (paletteLerp([['deepskyblue', 0],['white', 0.5],['lightpink', 1]],thisDist/this.distance));
for (let m = 1; m < lineLerp+1; m++) {
strokeWeight(1.5+weight/m);
line(0,0, smallStep.x, smallStep.y);
for (let m = 1; m < lineLerp+1; m++) {
strokeWeight(1.5+weight/m);
line(0,0, smallStep2.x, smallStep2.y);
this.population[i].drawFellow();
for (let i = 0; i < this.population.length; i++) {
this.population[i].moveFellow();
this.population[i].forceFellow();
function randomVector(min, max) {
} while (v.x < 1 && v.x > 0);
var d = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
createCanvas(windowWidth-10, windowHeight-10);
let maxDistance = windowWidth / 7.5;
net = new Network(pointCount, maxDistance);
function mouseClicked() {
let pos = createVector(mouseX, mouseY);
let direction = randomVector(-2.5, 2.5);
let acc = randomVector(-0.5, 0.5);
let nullVector = createVector(0, 0);
net.population.push(new Fellow(color('lightblue'), pos, direction, acc));