Mutiple lines of text in pwindow

Aug 27, 2009 at 10:34pm

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!

#45254
Aug 27, 2009 at 10:49pm

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.

#163067
Aug 27, 2009 at 11:13pm

like this :

– Pasted Max Patch, click to expand. –
#163068
Aug 27, 2009 at 11:27pm

here’s an example of the poly~ instance per line of a file method i described above.

save as “gltext2d_poly”

– Pasted Max Patch, click to expand. –

save as whatever

– Pasted Max Patch, click to expand. –
#163069
Aug 28, 2009 at 4:41pm

Wow!! Thanks a lot guys. This accomplishes exactly what I needed.

Thanks for taking the time to help me out!

#163070
Aug 28, 2009 at 4:58pm

Hi Rob,

loading .txt :
Maxwin gives an error message

jit.textfile: bad line

___

Which file format is supposed to be loaded?

#163071
Aug 28, 2009 at 6:38pm

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?

#163072
Aug 28, 2009 at 8:12pm

Yes indeed, thanks Rob.

#163073

You must be logged in to reply to this topic.