xxxxxxxxxx
float circX;
float circY;
float circD;
//Color variable for the color of the circle
color circColor;
//Color variables for the background gradient
color blue = color(159, 242, 232); // light blue
color pink = color(242, 202, 247); // light pink
// Counter that let's us cycle throuhg the lines of the Poem
int lineNum = 0;
void setup() {
size(500, 800, P2D);
//Make a circle with random X and Y coordinates, random colour on mouse hover
circX = random(width);
circY = random(height);
circD = random(10, 50);
circColor = color( 0, random(255), random(255));
// Animate at a slower framerate
frameRate(1.5);
}
void draw() {
background (#8BBFB1); // comment this out and uncomment the line below if you want the gradient to work
//gradientRect(0, 0, 500, 800, blue, pink); //Gradient (un-commen this for gradient, but it only works on processing, not here)
// Moon has different colors on mouse hover
if (dist(mouseX, mouseY, circX, circY) < circD*.5) {
fill(circColor);
} else {
fill(255);
}
// Circle
ellipse(circX, circY, circD, circD);
// halo
stroke(#FFEB03);
strokeWeight(4);
noFill();
ellipse (circX, circY, circD+15, circD+15);
noStroke();
// Poem Lines
String [] lines = new String [6];
lines[0] = "The moon has set, " ;
lines[1] = "And the Pleiades." ;
lines[2] = "Midnight." ;
lines[3] = "The hour has gone by" ;
lines[4] = "I sleep alone." ;
lines[5] = "- SAPPHO" ;
// Cycle through the whole poem line by line
text (lines[lineNum], width/4, random (height));
lineNum++; // cycle through the whole list
textSize (20);
// checking if array is out of range, i.e. > 6 here, then it resets the counter to 0 to start the cycle again
if (lineNum >= lines.length) {
lineNum = 0;
}
}
//Uncomment the above /* at top and bottom on your computer to activate this (only works on processing, not here)
// making a gradient background for the sketch
void gradientRect(int x, int y, int w, int h, color c1, color c2) {
beginShape();
fill(c1);
vertex(x, y);
vertex(x+w, y);
fill(c2);
vertex(x+w, y+h);
vertex(x, y+h);
endShape();
}
// reset the ellipse on keypress R
void keyPressed() {
if (key == 'r') {
circX = random(width);
circY = random(height);
circD = random(40) + 10;
circColor = color( random(255), random(255), random(255));
}
}