xxxxxxxxxx
//these values change how the paint drips
var dropDirectionRandomizer = 0.015;
var dropSizeRandomizer = 0.2;
//background
var bgCol = 255;
var drops = [];
var brush;
var dampening;
function setup() {
createCanvas(windowWidth, windowHeight);
background(bgCol);
//the dampening of the paint dripping
dampening = createVector(0, -0.05);
//create the brush
brush = new Brush(150, color(255, 100, 200));
}
function draw() {
for (var i = drops.length - 1; i >= 0; i--) {
drops[i].update();
drops[i].show();
//check wether a drop has stopped moving vertically, if thats the case, delete it
if (drops[i].vel.y <= 0) {
drops.splice(i, 1);
}
}
}
function mouseDragged() {
switch (mouseButton) {
case LEFT:
paint();
break;
}
}
function mousePressed() {
//left button paints, right button resets canvas
switch (mouseButton) {
case LEFT:
paint();
break;
case RIGHT:
drops = [];
background(bgCol);
break;
}
}
function paint() {
var mousePos = createVector(mouseX, mouseY);
drops = concat(drops, brush.paint(mousePos));
}
//this function returns a random vector inside a circle with a given radius
p5.Vector.randomInsideCircle = function (r) {
var vector = this.random2D();
vector.x *= random(r);
vector.y *= random(r);
return vector;
}