float x = 0, y = 0;
String message = "Message";
String[] fontNames;
int FontIndex;
int count;
int counter = 0;
int MIN_FONT_SIZE = 4;
char letter;
int hue;
boolean col;
boolean start = false;
String colors = "Rainbow";
void setup() {
size(1600, 1200);
background(0);
textSize(50);
text("Hit 0 to start. Type a message, and draw it around the screen!", 100, 100);
text("Hit 1 to change background to white. Hit 2 to change background to black.", 100, 200);
text("Hitting 3 makes the text change colors! Hitting 4 makes it rainbow!", 100, 300);
fontNames = PFont.list();
textAlign(LEFT);
fill(0);
colorMode(HSB);
}
void draw() {
if(start) {
if(mousePressed) {
float d = dist(x, y, mouseX, mouseY);
letter = message.charAt(counter % message.length());
if(d > textWidth(letter)) {
float angle = atan2(mouseY-y, mouseX-x);
counter++;
count ++;
if(counter % 19 == 0) {
if(counter / 20 < 4) {
FontIndex++;
} else {
FontIndex = 0;
}
}
PFont curFont = createFont(fontNames[FontIndex], 50);
translate(x, y);
rotate(angle);
if(col) {
fill(hue, map(x, 0, 800, 0, 255), map(y, 0, 800, 0, 255));
}else {
fill(counter % 360, map(x, 0, 800, 0, 255), map(y, 0, 800, 0, 255));
}
textFont(curFont);
textSize(MIN_FONT_SIZE + d/2);
text(letter, 0, 0);
resetMatrix();
x += textWidth(letter) * cos(angle);
y += textWidth(letter) * sin(angle);
}
}
fill(0);
noStroke();
rect(0, 0, 1600, 200);
fill(255);
textSize(50);
text(message, 100, 50);
text("Color: " + colors, 100, 100);
}
}
void mousePressed() {
x = mouseX;
y = mouseY;
}
void keyPressed() {
if(key == '1') {
background(255);
}else if(key == '2') {
background(0);
}else if(key == '0') {
background(255);
start = true;
}else if(key == '3') {
col = true;
hue = (int) random(0, 360);
colors = "Random";
}else if(key == '4') {
colors = "Rainbow";
col = false;
}
if(key == BACKSPACE) {
message = message.substring(0, message.length()-1);
}else if (key != CODED && key != '1' && key != '2' && key != '0' && key != '3' && key != '4') {
message += key;
}
}