jit.gl.text, get position for scrolling

Casper Leerink's icon

Hi,

I am working on a patch that is scrolling a large piece of text (larger then a max message can hold), so to scroll the text continuously, I need cut up the text into lines and scroll them one by one. (with two text objects)

I am not sure how to get the length of the line to correspond with the position attribute of the text.

So long question short, how can I find the position of the beginning and end of the text created by jit.gl.text?

Max Patch
Copy patch and select New From Clipboard in Max.


Martin Beck's icon

I think you can get all attribute values of jitter objects by sending messages with the following naming convention: get+attributename .
For example to get the line_length send a message "getline_length".
Not sure if it helps, but I use the following way for text https://cycling74.com/forums/how-to-make-those-stunning-videogame-glitches-!/replies/1#reply-5cd5f939f69e4079fde3b5c2
see upper right part of the patch red coloured jit.gl.text3d @linelength and a text object driven by a counter to select lines.

Casper Leerink's icon

Hi Martin,

Thank you for your reply! Very cool patch!

Excuse if I am wrong, but line_length is set by the user, it is just the maximum line length until a text is wrapped to the next line. Not the actual length of the text.

I did find something in text3d with getbounds, I will try that out for now, but if someone has a better way to go, please let me know! It turns out I need to multiply it to the scaling of the text. Then I get reasonable numbers I can work with.

mattyo's icon

I've only done it with monospaced fonts, but you can get the number of characters by taking your line of text and passing it to [spell] -> [zl len] which will give you the number of characters in a line. Figure out how much space one character takes up in your jit.window, multiply (and possibly offset), and you're ready to go. You could also pass the file to jit.textfile, attach a jit.spill to the center outlet, and zl.len that.

\M

Martin Beck's icon

Hello Casper,

you are right line_length only defines the wrap limit and getbounds multiplied by scaling seems to be a solution.
Can you specify some more details what you mean by scrolling - which direction horizontal / vertical, continuos movement or jumping, how many lines are visible at once....? Can you include text in your example patch to illustrate the amounting and formatting of text ?
...this thread includes some interesting ways:

Casper Leerink's icon

Hi Everyone,

Thanks for all the replies!

Here is the patch I have so far. I will also mess with rotation later. But for now, just horizontal scrolling is my goal.

In the subpatch get_lines lines from a multiline textfile are output.

I still have trouble with the start position, when is the line going off the dimension, because even though I have a jit.gl.node, it still seems to differ on how big the window of the jit.world is.

Thank you!

Max Patch
Copy patch and select New From Clipboard in Max.



Casper Leerink's icon

Also I have some trouble with the getbounds message arriving before the bounds are updated, sometimes it gives the bounds from the previous text. Even though I use trigger and deferlow.

Martin Beck's icon

Hello Casper,

I can reproduce the behaviour of getbounds message arriving before the bounds are updated. I solved it by delaying the message explicitly by 20ms. I don't know if this approach here helps you and if it is sufficiently generic for what you want to do, but this is my best approach so far:

Max Patch
Copy patch and select New From Clipboard in Max.