String file = "https://www.mit.edu/~ecprice/wordlist.10000";
String[] words = loadStrings(file);
String targetWord = "sleep";
int[] alphaIndex = new int[27];
int[] rWords = new int[targetWord.length()];
void setup() {
size(600, 600);
alphaIndex[26] = words.length;
char lIndex = 'a'; //which letter we're checking
int wIndex = 0; //Which word in the list we're on.
int alphaI = 1; //which letter we're indexing
while (lIndex <= 'z' && wIndex < words.length) {
if(words[wIndex].length() <=1){
wIndex++;
}
if (words[wIndex].charAt(0) != lIndex) {
alphaIndex[alphaI] = wIndex;
lIndex += 1;
wIndex++;
alphaI++;
} else {
wIndex++;
}
}
//println(alphaIndex);
for(int i = 0; i < targetWord.length(); i++){
int letterIndex = targetWord.charAt(i) - 97;
rWords[i] = (int)random(alphaIndex[letterIndex],alphaIndex[letterIndex+1]);
}
}
void draw(){
background(255);
float step = height/targetWord.length();
textSize(45);
textAlign(CENTER,CENTER);
text("Heck\nyeah\nI\n"+targetWord,100,300);
for(int i = 0; i < targetWord.length(); i++){
fill(0);
textSize(60);
textAlign(LEFT,CENTER);
text(targetWord.charAt(i),width/2, 50 + (i*step));
textSize(30);
textAlign(LEFT,CENTER);
text(words[rWords[i]].substring(1),width/2 + 50, 55 + (i*step));
}
}