lib/minigl/text.rb
# Draws text, breaking lines when needed and when explicitly caused by the
# "\n" character.
#
# Parameters:
# [text] The text to be drawn. Line breaks are allowed. You can use the
#        `<b>` tag for bold, `<i>` for italic and `<c=rrggbb>` for colors.
# [x] The horizontal reference for drawing the text. Works like in
#     +write_line+ for the +:left+, +:right+ and +:center+ modes. For the
#     +:justified+ mode, works the same as for +:left+.
# [y] The vertical reference for drawing the text. All text will be drawn
#     from this point down.
# [width] The maximum width for the lines of text. Line is broken when
#         this width is exceeded.
# [mode] The alignment of the text. Valid values are +:left+, +:right+,
#        +:center+ and +:justified+.
# [color] The color of the text, in hexadecimal RRGGBB format.
# [alpha] The opacity of the text. Valid values vary from 0 (fully
#         transparent) to 255 (fully opaque).
# [z_index] The z-order to draw the object. Objects with larger z-orders
#           will be drawn on top of the ones with smaller z-orders.
Draws text, breaking lines when needed and when explicitly caused by the
"\n" character.

[text] The text to be drawn. Line breaks are allowed.
Draws text breaking lines when needed and when explicitly caused by the " \ n " character . [ text ] The text to be drawn . Line breaks are allowed .
def write_breaking(text, x, y, width, mode = :left, color = 0, alpha = 0xff, z_index = 0)
      color = (alpha << 24) | color
      text.split("\n").each do |p|
        if mode == :justified
          y = write_paragraph_justified p, x, y, width, color, z_index
        else
          rel =
            case mode
            when :left then 0
            when :center then 0.5
            when :right then 1
            else 0
            end
          y = write_paragraph p, x, y, width, rel, color, z_index
        end
      end
    end
def write_breaking ( text , x , y , width , mode = :left , color = 0 , alpha = 0xff , z_index = 0 ) color = ( alpha << 24 ) | color text . split ( "\n" ) . each do | p | if mode == :justified y = write_paragraph_justified p , x , y , width , color , z_index else rel = case mode when :left then 0 when :center then 0.5 when :right then 1 else 0 end y = write_paragraph p , x , y , width , rel , color , z_index end end end
Draws text, breaking lines when needed and when explicitly caused by the
"\n" character.
Draws text breaking lines when needed and when explicitly caused by the " \ n " character .
text
<not_specific>
x
<not_specific>
y
<not_specific>
width
<not_specific>
mode
<not_specific>
color
<not_specific>
alpha
<not_specific>
z_index
<not_specific>