Permalink
Browse files

ImageFont#render_to now takes an option hash.

  • Loading branch information...
1 parent ee310c2 commit db6b6577cd316ba584387258106432b02a40f92c @jacius jacius committed Feb 18, 2011
Showing with 15 additions and 7 deletions.
  1. +14 −6 lib/rubygame/imagefont.rb
  2. +1 −1 samples/demo_imagefont.rb
@@ -377,15 +377,23 @@ def render( text )
# Renders the given text onto the destination Surface.
#
- # text:: The text to render.
- # dest:: The destination Surface that the text will be rendered to.
- # pos:: The starting [x,y] position (top-left corner) for rendering
- # the text. Default: [0,0].
+ # text:: The text to render.
+ # dest:: The destination Surface to render the text on.
+ # options:: Options hash (see below).
+ #
+ # Recognized keys for the options hash are:
+ #
+ # :offset:: Shift the position of all text by [x,y] pixels.
+ # Default: [0,0].
#
- def render_to( text, dest, pos=[0,0] )
+ def render_to( text, dest, options={} )
+ options = {
+ :offset => [0,0]
+ }.merge(options)
+
whitespace = _parse_whitespace
- start_x, start_y = pos[0,2]
+ start_x, start_y = options[:offset][0,2]
cur_x, cur_y = start_x, start_y
font_height = height()
@@ -79,7 +79,7 @@ def handle_keystroke(event)
def redraw
@screen.fill(@background)
- @font.render_to(@message, @screen, [@padding, @padding])
+ @font.render_to(@message, @screen, :offset => [@padding, @padding])
@screen.update
end

0 comments on commit db6b657

Please sign in to comment.