xxxxxxxxxx
54
let f = 1;
function setup() {
createCanvas(400, 400);
background(220);
//stroke(0);
}
//ChatGPT
function drawLine(x, y, len, angle) {
if (len < 1) return; // Base case: if the length is too small, stop
// Calculate the end point of the line
let x2 = x + len * cos(angle);
let y2 = y + len * sin(angle);
line(x, y, x2, y2);
// Recursively draw the next line, turning to the right
drawLine(x2, y2, len * 0.8, angle + PI / 5);
}
function draw() {
let s = second();
let r = 0;
let b = 0;
let g = 0;
// for (let t = 1; t<100; t++){
t = (mouseX * mouseY) / 50;
if (s % 20) {
r = random(0, 255);
b = random(0, 255);
g = random(0, 255);
stroke(r, b, g);
}
if (mouseIsPressed && s % 5 == 0) {
f = f + 1;
}
else if (f > 1 && mouseIsPressed == false && s % 5 == 0){
f = f - 1
}
strokeWeight(f);
drawLine(200, 200, 100, t);
}
/*function mousePressed() {
if (second() % 5 == 0) {
f = f + 1;
}
else{
f = f - 1;
}
}
*/