xxxxxxxxxx
62
let drops = [];
let palette;
let bk;
function setup() {
createCanvas(640, 360);
palette = [
color('pink'),
color('lightblue'),
color('gray'),
color('lightgreen'),
color('aqua'),
color('beige')
];
bk = random(palette);
for(let i = 25; i < width;i+=50){
for(let j = 25; j < height; j+=50){
let x = map(i,0,width,25,width-25);
let y = map(j,0,height,25,height-25);
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();
}
}