Page 1 of 1

help with scrolling title

Posted: 02 Apr 2016, 12:41
by Funkencool
So if you've played BAR you might have noticed the scrolling song titles in the upper right hand corner. Now, I'm looking for a better way to implement them than how it is currently.

Code: Select all

local function scrollName()
    local length = string.len(trackLabel)
    if length > 35 then
        if labelVar > length then labelVar = 0 end
        songLabel:SetCaption(string.sub(trackLabel, labelVar)..string.sub(trackLabel,0, labelVar-1))
        labelVar = labelVar + 1
    end
end
As you can see it's quite hacky and horribly inefficient; lua has to create a new string, the length of the string, for every char in the string as it mashes the two halves together.

What I'd like to do is draw the title twice, one slightly after the other and move them slowly to the left while clipping them to within the parent chili window. I feel like this would be easy if I knew anything about drawing fonts but I don't, so any advice?

Re: help with scrolling title

Posted: 02 Apr 2016, 13:19
by Kloot
gl.Font.Print + gl.RenderToTexture + gl.Scissor + gl.Translate

Re: help with scrolling title

Posted: 03 Apr 2016, 07:56
by Funkencool
I looked more thoroughly into it and any performance impact is very negligible, but I'd still like something with more consistent results so I'll take your snippet and head to wiki!