xxxxxxxxxx
var autoHue = true;
var manualHue = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB);
background(0);
}
function draw() {
if (autoHue) { // The brush automatically rotates through the colors of the rainbow
fill(frameCount%360, 100, 100);
brush();
}
else { // Manual mode allows the color of the brush to be determined by the user
fill(manualHue, 100, 100);
brush();
}
}
function brush() { //The brush is formed of randomly sized ellipses rotating in a circle
noStroke();
translate(mouseX, mouseY);
rotate(frameCount);
var brushSize = random(1,40);
for(let i = -brushSize; i <= brushSize; i++) {
ellipse(i, 0, 100, 5);
}
}
/*
Press 'c' to clear the screen
Press 'H' to switch between manual color and auto color
*/
function keyTyped() {
if(key=='c') {
background(0);
}
if(key=='H'){
autoHue = !autoHue;
}
}
/*
When in manual color mode, press 'h' to make the color change
in the order of the rainbow
*/
function keyPressed(){
if(key=='h'){
if (manualHue < 360){
manualHue += 25;
}
else {
manualHue = 0;
}
}
}