Well, that's not what I gave...
In your case, that would be something like:
String input = myTextfield.getText();
String[] broken = input.split(""); // Defines and gets an array of stringsbut you have to choose between this solution and the toCharArray!
Let's take the latter, easier to convert to numbers.
Here is a possible way to using input:
Code:import controlP5.*;
ControlP5 controlP5;
int myColorBackground = 100;
int boxSize = 20;
char[] broken;
void draw() {
background(myColorBackground);
if (broken != null)
{
int cc;
for (int i = 0; i < broken.length; i++)
{
cc = Character.codePointAt(broken, i) - 32;
if (cc < 30)
{
cc = (int) map(cc, 0, 30, 0, 255);
fill(100, cc, 255 - cc);
}
else if (cc < 60)
{
cc = (int) map(cc, 30, 60, 0, 255);
fill(cc, 100, 255 - cc);
}
else if (cc < 120)
{
cc = (int) map(cc, 60, 120, 0, 255);
fill(cc, 255 - cc, 100);
}
else
{
cc = (int) map(cc, 120, 255, 0, 255);
fill(cc, 255 - cc, cc / 2);
}
rect(10 + i * boxSize, 10, boxSize, boxSize);
}
}
}
Textfield myTextfield;
void setup() {
size(800, 400);
frameRate(25);
controlP5 = new ControlP5(this);
myTextfield = controlP5.addTextfield("text1", 100, 290, 100, 20);
myTextfield.setFocus(true);
}
void controlEvent(ControlEvent theEvent) {
String input = myTextfield.getText();
broken = input.toCharArray();
}
Ugly, but it might give you some ideas... (use upper and lower case, symbols, accented chars, etc.).