Nokse22 / teleprompter

A simple Gtk4 application to read scrolling text from your screen
GNU General Public License v3.0
33 stars 14 forks source link

Allow for proportional animation speeds, independent of window and font sizes #24

Closed Cuperino closed 4 months ago

Cuperino commented 7 months ago

A common issue in new teleprompter software is that speed must be adjusted differently depending on the size of the typeface and the screen's resolution. Another, related, issue is small speed increments are easily noticeable when the animation starts but increments by the same amount become negligible as speed increases.

My solution to both of these problems is to count speed increments as "steps", then compute the animation speed based on: number of steps, the font-size and the screen's width, since that determines how many words can be seen at a given time.

This can be done in a few ways. On QPrompt, on Imaginary Teleprompter, and another teleprompter app I developed, I've used variations of the following equation:

speed = baseSpeed * ( |step| ^ accelerationCurvature )
velocity = speed * direction
milisecondsToReachEnd = (1000ms * travelDistance) / (speed * step)

step: Most people regard it as "speed", although it is not speed if the prompter can animate in reverse.
baseSpeed: a multiplier by, which can be automatically or manually adjusted based on the font's size relative to the screen
accelerationCurvature: a small exponent for the step, helps reach higher speeds with less steps. I've found a value of 1.3 makes a great default.
direction: -1 or 1 depending on which way you will animate

Given your project appears to follow Gnome's guidelines, I would advice hiding or not offering the ability to set the baseSpeed and accelerationCurve, and instead adjust for proportional animation speeds behind the scenes. In QPrompt I account for this by setting these additional factors at the base of the time calculation:

speed * step * fontSize / 2 * adjustedWidthOfTextBox

Resulting in:

milisecondsToReachEnd = (1000ms * travelDistance) / (speed * step * fontSize / 2 * adjustedWidthOfTextBox)

I hope this information is useful to you. Feel free to study my code to reference implementation details. it's all GPLv3, so feel free to derive from it under the same license. If you don't wish to derive, feel free to make use of the equations. These are mostly physics equations applied to teleprompters and therefore not copyrightable.

Cheers, Javier Author of QPrompt Teleprompter, co-author of Imaginary Teleprompter

Nokse22 commented 7 months ago

Thank you so much, these information are very useful to me. I tried to find a formula to do this, but it wasn't easy, first I tried to do it empirically, but it didn't work.

For now I just did something like speed = constant * user_speed * font_size / screen_width similar to what you suggested, but I probably need to calibrate it better (formula), because I present the speed setting in word per minute.