xxxxxxxxxx
30
let angle = 7;
let colorSlider;
function setup() {
createCanvas(440, 440);
background(220);
colorMode(HSB, 360, 100, 100); //to make the sketch more colorful, colormode is shifted to HSB, so that x coordinate of the mouse changes colors linearly
colorSlider = createSlider(100,255,150); //slider to change stauration and brightness
}
function draw() {
translate(width/2, height/2); //only the mouse coordinates in the upper-left quarter of the canvas is tracked
let colval = colorSlider.value();
for (let i = 0; i < 10; i++) {
rotate(angle);
strokeWeight(8);
stroke(mouseX, colval, colval/1.5, 0.5);
line(mouseX, mouseY, pmouseX, pmouseY); //trace the mouse
push();
scale(1, -1); //reflect vertically
line(mouseX, mouseY, pmouseX, pmouseY);
pop();
push();
scale(-1, 1); //reflect horizontally
line(mouseX, mouseY, pmouseX, pmouseY);
pop();
}
}