Dear openFrameworkers,
for almost an hour I’m trying to cast an int or a string to a specific length, for example three digits (with leading zeros).
I don’t need int but string in my case, so maybe the conversion to int is not even necessary?
I tried the following, but it doesn’t work.
for (auto xPos = 0; xPos < width; xPos++) {
for (auto yPos = 0; yPos < height; yPos++) {
auto color = ofToString(img.getColor(xPos, yPos));
auto color_string = ofSplitString(color, ", ");
auto color_int_r = ofToInt(color_string.at(0));
auto color_int_g = ofToInt(color_string.at(1));
auto color_int_b = ofToInt(color_string.at(2));
auto x = ofToString(xPos % 100);
auto y = ofToString(yPos % 100);
auto r = ofToString(color_int_r % 100);
auto g = ofToString(color_int_g % 100);
auto b = ofToString(color_int_b % 100);
Thank you very much for your help!
PS: I need to store the leading zeros in the variables, I do not only need this conversion in my cout …