Skip to content

Instantly share code, notes, and snippets.

@ocello3
Created December 29, 2015 13:38
Show Gist options
  • Save ocello3/7f548d4ba3321e12f18b to your computer and use it in GitHub Desktop.
Save ocello3/7f548d4ba3321e12f18b to your computer and use it in GitHub Desktop.
PFont openSans;
char t1 = 't';
char w = 'w';
char i = 'i';
char t2 = 't';
char t3 = 't';
char e = 'e';
char r = 'r';
float t1_w, w_w, i_w, t2_w, t3_w, e_w, r_w;
float c_length;
float t1_x, w_x, i_x, t2_x, t3_x, e_x, r_x;
float t1_y, w_y, i_y, t2_y, t3_y, e_y, r_y;
float t1_yFinal, w_yFinal, i_yFinal, t2_yFinal, t3_yFinal, e_yFinal, r_yFinal;
float t1_ySpeed, w_ySpeed, i_ySpeed, t2_ySpeed, t3_ySpeed, e_ySpeed, r_ySpeed;
float t1_c, w_c, i_c, t2_c, t3_c, e_c, r_c;
void setup(){
size(300, 300);
openSans = createFont("OpenSans-Bold.ttf", 34);
textFont(openSans);
t1_w = textWidth(t1);
w_w = textWidth(w);
i_w = textWidth(i);
t2_w = textWidth(t2);
t3_w = textWidth(t3);
e_w = textWidth(e);
r_w = textWidth(r);
c_length = t1_w + w_w + i_w + t2_w + t3_w + e_w + r_w;
t1_x = (width - c_length)/2;
w_x = t1_x + t1_w;
i_x = w_x + w_w;
t2_x = i_x + i_w;
t3_x = t2_x + t2_w;
e_x = t3_x + t3_w;
r_x = e_x + e_w;
t1_y = 0;
w_y = 0;
i_y = 0;
t2_y = 0;
t3_y = 0;
e_y = 0;
r_y = 0;
t1_yFinal = height/2;
w_yFinal = height/2;
i_yFinal = height/2;
t2_yFinal = height/2;
t3_yFinal = height/2;
e_yFinal = height/2;
r_yFinal = height/2;
t1_ySpeed = random(0.01, 0.1);
w_ySpeed = random(0.01, 0.1);
i_ySpeed = random(0.01, 0.1);
t2_ySpeed = random(0.01, 0.1);
t3_ySpeed = random(0.01, 0.1);
e_ySpeed = random(0.01, 0.1);
r_ySpeed = random(0.01, 0.1);
t1_c = 204;
w_c = 204;
i_c = 204;
t2_c = 204;
t3_c = 204;
e_c = 204;
r_c = 204;
}
void draw(){
background(204);
t1_y += (t1_yFinal - t1_y) * t1_ySpeed;
w_y += (w_yFinal - w_y) * w_ySpeed;
i_y += (i_yFinal - i_y) * i_ySpeed;
t2_y += (t2_yFinal - t2_y) * t2_ySpeed;
t3_y += (t3_yFinal - t3_y) * t3_ySpeed;
e_y += (e_yFinal - e_y) * e_ySpeed;
r_y += (r_yFinal - r_y) * r_ySpeed;
t1_c = (map(t1_y, 0, height/2, 0, 204) - 204) * (-1);
w_c = (map(w_y, 0, height/2, 0, 204) - 204) * (-1);
i_c = (map(i_y, 0, height/2, 0, 204) - 204) * (-1);
t2_c = (map(t2_y, 0, height/2, 0, 204) - 204) * (-1);
t3_c = (map(t3_y, 0, height/2, 0, 204) - 204) * (-1);
e_c = (map(e_y, 0, height/2, 0, 204) - 204) * (-1);
r_c = (map(r_y, 0, height/2, 0, 204) - 204) * (-1);
fill(t1_c);
text(t1, t1_x, t1_y);
fill(w_c);
text(w, w_x, w_y);
fill(i_c);
text(i, i_x, i_y);
fill(t2_c);
text(t2, t2_x, t2_y);
fill(t3_c);
text(t3, t3_x, t3_y);
fill(e_c);
text(e, e_x, e_y);
fill(r_c);
text(r, r_x, r_y);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment