Method: MiniGL::TextHelper#write_breaking
- Defined in:
- lib/minigl/text.rb
#write_breaking(text, x, y, width, mode = :left, color = 0, alpha = 0xff, z_index = 0, scale_x = nil, scale_y = nil, line_spacing = nil) ⇒ Object
- 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.
- scale_x
-
The horizontal scaling of the text. If
nil
, this instance’s @scale_x value will be used. - scale_y
-
The vertical scaling of the text. If
nil
, this instance’s @scale_y value will be used. - line_spacing
-
The spacing between lines, in pixels. If
nil
, this instance’s @line_spacing value will be used.
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/minigl/text.rb', line 252 def write_breaking(text, x, y, width, mode = :left, color = 0, alpha = 0xff, z_index = 0, scale_x = nil, scale_y = nil, line_spacing = nil) line_spacing = @line_spacing if line_spacing.nil? scale_x = @scale_x if scale_x.nil? scale_y = @scale_y if scale_y.nil? color = (alpha << 24) | color text.split("\n").each do |p| if mode == :justified y = write_paragraph_justified p, x, y, width, color, z_index, scale_x, scale_y, line_spacing 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, scale_x, scale_y, line_spacing end end end |