Hi everyone, I am new here. hi hi!
I am a visual artist and I project text (poetry) to an audience.
I would love some help in making a long text appearing and disappearing.
At the moment I have only two words. In my case I need the text to be long, sometime even 100 words or more.
this is what I have so far:
String oneName = “i don’ t want to be”;
String otherName = “you”;
String displayed ="";
int interval = 500; // 2s
int time;
PFont font;
void setup() {
size(300, 300);
font = createFont(“arial”, 26);
background(0);
displayed = oneName;
time = millis();
textFont(font);
fill(255);
}
thanks for the quick reply. I think there is already a timer in (interval) . I need only an option that allows the text to be longer, at the moment it is 2 words only… I would like to avoid to write word by word, but have the option to fill in a longer text, 100 words for example all in once and make the blinking one after the next. The text should be blinking, I am happy with blinking and appearing line by line. A fading option would be great in the future.We did code something like that, using an HTML script/ but it was ages ago…
Thanks kll!
Chrisir, I am trying to have the text appearing not in the same window but in a sequence. Basically it would be as it is but with a longer text. I wnted to avoid typing strings and maybe just add a lot of text with some separation to project a few words and then again another few and other few. I call it the concept shooter, it is like you would be shooting words, like bullets. As for example: “you are” (first window), “in a dream” second window", “you call reality” third window. If I use your code, they will appear all in the same window. My aim is to add a really long text and have it all appear consequentially. Not sure I am able to explain it well… beside, thanks for the help!
store text in a separate text file line by line and load it using loadStrings() and for loop over the resulting array (or rather use an index i for the array and increase i when you go to the next screen in the timer if clause)
Alternatively you can store the text like I did above and separate your screens with eg. # ( … = “you are # now here # to party #“ ; )
Then use split() with # to get an array then for loop over it (or rather use i like above) - see reference
Thank Chrisir. Indeed to have the text separate way (testing it in a note pad) makes a lot of sense, however I am not able to get it to work. I think my level of knowledge is very low and I am really shy to admit it but it is the way it is. But will keep on trying with your suggestions. Maybe a good way for me to learn more!
Found this solution for now. Lots of typing, and not a lame copy and paste,but it works:
string[][] story = {
{“once upon a time”, “there was a girl”, “called little red”, “riding hood”},
{“once upon a time”, “there was a wolf”, “called big bad”}
};
int counter;
int storyNum;
here is my approach with # as a separator (other than with your code you can have 1000 text screens and the code doesn’t get longer except for the initial text that gets splitted)
// shows a text section by section.
// Separate sections by "#", text in one go.
String myText =
"once upon a time#there was a girl#called little red#riding hood#"
+"once upon a time#there was a wolf#called big bad#"
+"Lorem ipsum dolor sit amet,#consectetuer adipiscing elit. #Aenean commodo ligula eget dolor.#"
+"Aenean massa. #Cum sociis natoque penatibus et magnis dis parturient montes, #nascetur ridiculus mus. #Donec quam felis, #ultricies nec, #pellentesque eu,#"
+"pretium quis, sem. Nulla consequat massa quis enim. #Donec pede justo, fringilla vel, #aliquet nec, vulputate eget, arcu. #In enim justo, rhoncus ut, #imperdiet a, venenatis vitae, justo.#"
+"Nullam dictum felis eu pede mollis pretium. #Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. #Aenean vulputate eleifend tellus. #Aenean leo ligula, porttitor eu,#"
+"consequat vitae, eleifend ac, enim. #Aliquam lorem ante, dapibus in, #viverra quis, feugiat a, tellus.";
// our array (it's a list)
String[] textOutput;
// which element in the array is currently shown
int i=0;
// for the timer:
int time;
void setup() {
size(1200, 1000);
background(0);
textOutput = split (myText, "#" );
textAlign(CENTER);
textSize(36);
time=millis();
}//func
void draw() {
background(0);
text(textOutput[i], width/2, height/2);
if (millis()-time > 1200) {
time=millis();
// color for text
fill(random(100, 255), random(100, 255), random(100, 255));
i++; // next element in the array
// check end of array
if (i >= textOutput.length) {
i=0; // reset
}//if
}//if
//
}//func
//
new version that loads a text file and displays it
similar to the version above but loading a file
file must be in sketch folder
inside the file, line breaks are allowed (but later ignored), the # signs are necessary
// shows a text section by section.
// Separate sections by "#", text in one go.
// our array (it's a list, each element is a text section formerly separated by #)
String[] textOutput;
// which element in the array is currently shown
int i=0;
// for the timer:
int time;
void setup() {
size(1200, 1000);
background(0);
String[] myText;
myText=loadStrings("text.txt");
// using join (to join all lines together first) and then split (to separate only at #)
textOutput = split (join(myText, ' '), "#" );
textAlign(CENTER);
textSize(36);
time=millis();
}//func
void draw() {
background(0);
text(textOutput[i], width/2, height/2);
if (millis()-time > 1200) {
time=millis();
// color for text
fill(random(100, 255), random(100, 255), random(100, 255));
i++; // next element in the array
// check end of array
if (i >= textOutput.length) {
i=0; // reset
}//if
}//if
//
}//func
//