Hello,
I am trying to make an image of the bible, as someone with Letter-Color Synaesthesia would see it (kind of - I have not mapped the correct colors yet). I have made a huge text file of the entire bible (and removed line breaks) and want to read this in with the program below.
I have tried two ways and have had trouble with both.
First I just pasted the whole text of the bible in as a string (str1). This caused the program to crash because it was too long.
Then I wanted to read from a file, but I am not sure how to go about doing that as once I read from a file the "char letter = str1.charAt(z);" is no longer working.
The code (it is rough) is below. Any help would be greatly appreciated.
Daniel
Quote:
String str1 = "aaasdf";
String str2[] = loadStrings("test.txt");
int numChars = 26;
color[] colors = new color[numChars];
int x=0;
int y=0;
void setup()
{
size(1000, 1000);
noStroke();
colorMode(RGB, numChars);
background(numChars/2);
// Set a gray value for each key
for(int i=0; i<numChars; i++) {
colors[i] = color(0, 0, i);
}
}
void draw() {
for(int z=0; z<str1.length(); z++) {
char letter = str1.charAt(z);
if ( letter >= 'A' && letter <= 'z') {
if (letter <= 'Z') {
fill(colors[letter - 'A']);
} else {
fill(colors[letter - 'a']);
}
rect(x,y, 5,5);
x+=5;
if (x > width-5) {
y+=5;
x=0;
}
}
}
}