So I needed this functionality for the current project I'm working on (see: Vortex Voyager).
Here it is, go crazy:
def draw_with_linebreaks(text, x, y, z, factor_x = 1, factor_y = 1, color = 0xffffffff, mode = :default, y_padding=0)
text.split("\n").each_with_index() do |line, i|
self.draw(line, x, y+(i*(self.height+y_padding)), z, factor_x, factor_y, color, mode)
Would perform slightly better, thanks for the suggestion!
Not sure I'll use it, because I think I need dynamic lines of text. (And it would be kind of weird just updating the image)
You can't manage your own line-spacing with that method though. It would perform better if the text was static, but if it was changing (e.g. if you were adding a few characters a second) it would create a lot of new Image objects. Still, valid to mention it!
Cool! I will definitely be trying this out!
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill