Mutiple lines of text in pwindow
Hi all,
i was wondering if anybody might be able to point me in the right direction here.
what is the best way to get multiple lines of text into the pwindow?
i am looking at using, text -> coll -> jit.fill -> jit.matrix -> jit.gl.text2d
i am looking at text as opposed to jit.text because text can query and report the number of lines in a file and this doesn't seem to be a feature of the jit.text object. Well at least not documented as far as i can tell.
Is there a better solution than this?
i would like to be able to scroll upwards to read through a text file in the pwindow, but also i would like to be able to use seperate effects for each line.
is this possible?
Thank you for your time and attention!
you can plug the left input of jit.textfile directly into a jit.gl.text2d, and it will render it with whatever line breaks are in the text file.
to get the number of lines with jit.textfile, send the matrix into a jit.matrixinfo. the second dimension is the number of lines. the first dimension is the number of characters in the longest line of the file.
to scroll, you can interpolate the y-position of the jit.gl.text2d.
if you want to have different effects per line, you will probably want to encapsulate the text2d in a poly~ object (number of voices equal to number of lines of the file) and send each poly~ instance a matrix from the jit.textfile using the line message (and connecting to the middle outlet of textfile, instead of left).
in this case, scrolling will be tricker. i recommend using drawobject message of gl.sketch to position each line, then scroll using the sketch's y-position.
like this :
here's an example of the poly~ instance per line of a file method i described above.
save as "gltext2d_poly"
save as whatever
Wow!! Thanks a lot guys. This accomplishes exactly what I needed.
Thanks for taking the time to help me out!
Hi Rob,
loading .txt :
Maxwin gives an error message
jit.textfile: bad line
___
Which file format is supposed to be loaded?
i think that's just the silly way i iterate the lines. it doesn't check if it's reached the maximum number, so when you ask for a line that's past the max, you get that error.
should work regardless no?
Yes indeed, thanks Rob.