jit.gl.text, get position for scrolling

    May 20 2019 | 1:15 am
    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?

    • May 20 2019 | 5:42 am
      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.
    • May 20 2019 | 3:55 pm
      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.
    • May 20 2019 | 8:40 pm
      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.
    • May 21 2019 | 4:55 pm
      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:
    • May 22 2019 | 9:13 am
      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!
    • May 22 2019 | 9:27 am
      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.
    • May 23 2019 | 11:24 pm
      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: