xxxxxxxxxx
46
let x = 0;
let y = 0;
let stepSize = 30;
let minDiameter = 50;
let maxDiameter = 200;
function setup() {
createCanvas(windowWidth, windowHeight);
background('#333333')
smooth();
}
function draw() {
if (mouseIsPressed) {
let d = dist(x, y, mouseX, mouseY);
if (d > stepSize) {
let angle = atan2(mouseY - y, mouseX - x);
push();
translate(mouseX, mouseY);
rotate(angle + PI);
drawEllipseModul(d);
pop();
x = x + cos(angle) * stepSize;
y = y + sin(angle) * stepSize;
}
}
}
function drawEllipseModul(diameter) {
let modulSize = map(mouseY, 0, height, 20, 100); // Map mouseY position to modulSize between 20 and 80
// Draw the ellipse with the given diameter and modulSize
fill('white');
stroke('black');
strokeWeight(0.5);
ellipse(0, 0, diameter * 1.5, modulSize);
}
function keyPressed() {
if (key === '0') {
saveCanvas('sketch3', 'png');
}
}