if (dots[i].color === [255, 0, 0]); { dots[i].recoveryRate += 1; if (dots[i].recoveryRate === 1000000000000000000000); { dots[i].color = [0, 0, 255] dots[i].recoveryRate = 0; }
class Dot { constructor(x, y, color, speed) { this.x = x this.y = y this.color = color this.speed = speed this.recoveryRate = 0; }}
let frameCount ;let x = 320;let y = 180;let xspeed = 5;let yspeed = 2;let speeds = [[5, 2], [2, 5]]let array = [[320, 180], [450, 120]]let colors = [[255, 0, 0], [0, 255, 255]]let r = 10;let dots = [new Dot(320, 180, [255, 0, 0], [5, 2]), new Dot(450, 120, [255, 255, 0], [2, 5])]function setup() { createCanvas(640, 360);}
function draw() { background(255); for (let i = 0; i <= 1; i++) { let c = color(dots[i].color[0], dots[i].color[1], dots[i].color[2]); noStroke(); fill(c); let x = dots[i].x let y = dots[i].y ellipse(x, y, r*2, r*2); x += dots[i].speed[0]; y += dots[i].speed[1]; if (x > width - r || x < r) { dots[i].speed[0] = -dots[i].speed[0]; } if (y > height - r || y < r) { dots[i].speed[1] = -dots[i].speed[1]; } dots[i].x = x dots[i].y = y if (dots[i].color === [255, 0, 0]) { console.log("here") if (random(1, 5) < 5); { dots[i].color = [0, 0, 255]; }} intersect(i) }}
function intersect(i) { for (let x = 0; x < dots.length; x++) { if (i!==x); { if (dots[x].color === [255, 0, 0]); { if (dots[i].color === [255, 255, 0]); { var d = dist(dots[x].x, dots[x].y, dots[i].x, dots[i].y); if (d < r + r) { dots[i].color = [255, 0, 0] } else { return false; } }}} }}
class Dot { constructor(x, y, color, speed) { this.x = x this.y = y this.color = color this.speed = speed this.recoveryRate = 0; }}
let infected = 5;
let x = 320;let y = 180;let xspeed = 5;let yspeed = 2;let speeds = [[5, 2], [2, 5]]let array = [[320, 180], [450, 120]]let colors = [[255, 0, 0], [0, 255, 255]]let r = 10;let dots = [new Dot(320, 180, [255, 0, 0], [5, 2]), new Dot(450, 120, [255, 255, 0], [2, 5])]function setup() { createCanvas(640, 360);
for (let y = 0; y <=17-infected; y++) { append(dots, new Dot(random(100, 400), random(100, 400), [255, 255, 0], [random(-5, 5), random(-5, 5)])); } for (let y = 0; y <=infected; y++) { append(dots, new Dot(random(100, 400), random(100, 400), [255, 0, 0], [random(-5, 5), random(-5, 5)])); }}
function draw() { background(255); for (let i = 0; i <= 19; i++) {
let c = color(dots[i].color[0], dots[i].color[1], dots[i].color[2]); noStroke(); fill(c); let x = dots[i].x let y = dots[i].y ellipse(x, y, r*2, r*2); x += dots[i].speed[0]; y += dots[i].speed[1]; if (x > width - r || x < r) { dots[i].speed[0] = -dots[i].speed[0]; } if (y > height - r || y < r) { dots[i].speed[1] = -dots[i].speed[1]; } dots[i].x = x dots[i].y = y
if (dots[i].color[0] === 255) { if (dots[i].color[1] === 0) { if (random(1, 1000) < 0.005*1000) {
dots[i].color = [0, 0, 255]; }}} intersect(i) } }
function intersect(i) { for (let x = 0; x < dots.length; x++) { if (i!==x); {
if (dots[x].color[0] === 255) { if (dots[x].color[1] === 0) { if (dots[i].color[1] === 255) {