lib/minigl/text.rb in minigl-1.2.3 vs lib/minigl/text.rb in minigl-1.2.4

- old
+ new

@@ -3,22 +3,24 @@ def initialize font, line_spacing = 0 @font = font @line_spacing = line_spacing end - def write_line text, x, y, mode = :left, color = 0xffffffff + def write_line text, x, y, mode = :left, color = 0, alpha = 0xff + color = (alpha << 24) | color rel = case mode when :left then 0 when :center then 0.5 when :right then 1 else 0 end @font.draw_rel text, x, y, 0, rel, 0, 1, 1, color end - def write_breaking text, x, y, width, mode = :left, color = 0xffffffff + def write_breaking text, x, y, width, mode = :left, color = 0, alpha = 0xff + color = (alpha << 24) | color text.split("\n").each do |p| if mode == :justified y = write_paragraph_justified p, x, y, width, color else rel = @@ -31,9 +33,11 @@ y = write_paragraph p, x, y, width, rel, color end end end + private + def write_paragraph text, x, y, width, rel, color line = "" line_width = 0 text.split(' ').each do |word| w = @font.text_width word