Module: Tea::Blitting
Overview
The Blitting mixin allows objects with SDL::Surface to draw or ‘blit’ onto each other.
To use this mixin, include it and write/alias a blittable_buffer method that gets the SDL::Surface.
include Blitting
def blittable_buffer
@my_sdl_surface
end
Instance Method Summary collapse
-
#blit(source_blittable, x, y) ⇒ Object
Draw the source_blittable onto the current object at (x, y).
Instance Method Details
#blit(source_blittable, x, y) ⇒ Object
Draw the source_blittable onto the current object at (x, y).
source_blittable needs to include the Blitting mixin too.
23 24 25 26 27 |
# File 'lib/tea/m_blitting.rb', line 23 def blit(source_blittable, x, y) src = source_blittable.send(:blittable_buffer) dest = blittable_buffer SDL::Surface.blit src, 0, 0, src.w, src.h, dest, x, y end |