xxxxxxxxxx
82
//
// The Symmetrical Scribble Machine will draw lines from your mouse randomly with symmetry
//
// Directions:
//
// Click and Hold to randomly draw white lines
//
// Hold Shift + Hold Click to draw rainbow lines
//
// Hold Alt + Click will delete the canvas
//
const spreadAmount = 12;
let strokeC;
function setup() {
createCanvas(400, 400);
background(0);
let initialLock = false;
let colorLock = false;
let lastX,
lastY,
newX,
newY = 0;
strokeColor = color(255, 255, 255);
}
function draw() {
if (mouseIsPressed) {
if (!colorLock) {
strokeColor = color(255, 255, 255);
} else {
changeColors();
}
strokeWeight(1.5);
stroke(strokeColor);
if (!initialLock) {
initialLock = true;
newX = mouseX + random(-spreadAmount, spreadAmount);
newY = mouseY + random(-spreadAmount, spreadAmount);
line(mouseX, mouseY, newX, newY);
line(width - mouseX, mouseY, width - newX, newY);
lastX = newX;
lastY = newY;
} else {
newX = lastX + random(-spreadAmount, spreadAmount);
newY = lastY + random(-spreadAmount, spreadAmount);
line(lastX, lastY, newX, newY);
line(width - lastX, lastY, width - newX, newY);
lastX = newX;
lastY = newY;
}
} else {
initialLock = false;
}
}
function mousePressed(event) {
if (event.shiftKey) {
colorLock = true;
} else if (event.altKey) {
background(0);
} else {
strokeColor = color(255, 255, 255);
colorLock = false;
}
}
function changeColors() {
strokeColor = color(random(0, 255), random(0, 255), random(0, 255));
}