Original Code
String message = "tickle";
float x, y; // X and Y coordinates of text
float hr, vr; // horizontal and vertical radius of the text
void setup() {
size(640, 360);
// Create the font
textFont(createFont("SourceCodePro-Regular.ttf", 36));
textAlign(CENTER, CENTER);
hr = textWidth(message) / 2;
vr = (textAscent() + textDescent()) / 2;
noStroke();
x = width / 2;
y = height / 2;
}
void draw() {
// Instead of clearing the background, fade it by drawing
// a semi-transparent rectangle on top
fill(204, 120);
rect(0, 0, width, height);
// If the cursor is over the text, change the position
if (abs(mouseX - x) < hr &&
abs(mouseY - y) < vr) {
x += random(-5, 5);
y += random(-5, 5);
}
fill(0);
text("tickle", x, y);
}
Modified Code
String message = "I've got the jitters!";float x, y; // X and Y coordinates of text
float hr, vr; // horizontal and vertical radius of the text
void setup() {
size(1280, 675);
// Create the font
textFont(createFont("SourceCodePro-Regular.ttf", 75));
textAlign(CENTER, CENTER);
hr = textWidth(message) / 2;
vr = (textAscent() + textDescent()) / 2;
noStroke();
x = width / 2;
y = height / 2;
}
void draw() {
// Instead of clearing the background, fade it by drawing
// a semi-transparent rectangle on top
fill(204, 120);
rect(0, 0, width, height);
// If the cursor is over the text, change the position
if (abs(mouseX - x) < hr &&
abs(mouseY - y) < vr) {
x += random(-10, 10);
y += random(-10, 10);
}
fill(0);
text("I've got the jitters!", x, y);
}
No comments:
Post a Comment