如何用 pascal 或任何编程语言实现字幕文本?
我记得有一次在学校,我们的任务是用 Pascal 编程一个字幕文本,即从左到右移动的文本。我还记得我完全不知道如何做到这一点。如今我仍然不是一个好的程序员,想问你们如何做到这一点——当然没有任何类型的库。
我想到将任何字母放入数组值中,然后例如每秒将数组值向右移动一个位置或其他位置。不知道这是否是一个好的“算法”。
你们觉得怎么样?
I remember once in school we had the task of programming a marquee text in pascal, that is a text that moves from left to right. I also remember that I did not have the slightest clue how to do this. Nowadays I'm still not a good programmer, and wanted to ask you guys how you would do it - without any sort of libraries of course.
I thought of putting any letter in an array value and then for example every second move the array values one position to the right or something. Don't know if thats a good "algorithm".
What do you guys think?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
例如,在Python中我会这样做:
你只需将起始字母从左向右移动(考虑到字母的数量,这就是我取模(%)的原因),然后将字符串的其余部分移动到另一侧。
你会得到:
希望我理解你的问题。
For example in python I would do :
You just move the starting letter from left to right (respecting the number of letters that's why I take the modulo (%)) and you move the rest of the string on the other side.
and you would get :
Hope I understood your problem.
对于表单应用程序,我建议创建一个线程,以指定的间隔通过 x 轴移动文本标签。
For a form applicaiton, I can suggest creating a thread that moves the text label through x axis with specified interval.