xxxxxxxxxx
71
let drops = [];
let r = 1;
let a = 0;
let palette;
let bk;
function setup() {
createCanvas(640, 360);
palette = [
color(11, 106, 136),
color(45, 197, 244),
color(112, 50, 126),
color(146, 83, 161),
color(164, 41, 99),
color(236, 1, 90),
color(240, 99, 164),
color(241, 97, 100),
color(248, 158, 79),
color(252, 238, 33),
];
bk = random(palette);
for (let i = 0; i < 5; i++) {
let x = random(width);
let y = random(height);
let r = random(100, 200);
addInk(x, y, r, random(palette));
}
for (let i = 0; i < 50; i++) {
let x = random(width);
let y = random(height);
let r = random(5, 50);
addInk(x, y, r, random(palette));
}
}
function tineLine(v, x, y, z, c) {
for (let drop of drops) {
drop.tine(v, x, y, z, c);
}
}
function addInk(x, y, r, col) {
let drop = new Drop(x, y, r, col);
for (let other of drops) {
other.marble(drop);
}
drops.push(drop);
}
let val = 4;
function draw() {
if (mouseIsPressed) {
let v1 = createVector(pmouseX, pmouseY);
let v2 = createVector(mouseX, mouseY);
v2.sub(v1);
if (v2.mag() > 0.1) {
v2.normalize();
tineLine(v2, mouseX, mouseY, 2, 16);
}
}
background(bk);
for (let drop of drops) {
drop.show();
}
}