xxxxxxxxxx
48
//key "b" for background color
// key "f" for brush color
var painting;
function setup() {
initializeFields();
createCanvas(900, 700);
background(253, 253, 250);
fill(96, 169, 166, 160);
frameRate(120);
stroke(10);
}
function draw() {
noStroke();
rect(0, 0, width, 20);
textSize(12);
text("f - change brush color", width-170, height-30);
text("b - change background color", width-170, height-45);
if (painting === true) {
var ellipseHW = random(40, 90);
stroke(0, 20);
ellipse(mouseX, mouseY, ellipseHW, ellipseHW);
}
}
function mouseClicked() {
painting = !painting;
print(painting);
}
function keyReleased() {
if (key == 'b' || key == 'B') {
background(random(200, 230), random(210, 220), random(200, 210));
}
if (key == 'f' || key == 'F') {
fill(random(160, 255), random(160, 220), random(160, 220), random(140, 210));
}
if (key == 's' || key == 'S') {
save("image-" + frameCount + ".jpg");
}
}
function initializeFields() {
painting = false;
}