Class: DXRubySDL::RenderTarget

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/dxruby_sdl/render_target.rb

Instance Method Summary collapse

Constructor Details

#initialize(width, height, color) ⇒ RenderTarget

Returns a new instance of RenderTarget.



9
10
11
12
# File 'lib/dxruby_sdl/render_target.rb', line 9

def initialize(width, height, color)
  @_image = Image.new(width, height, color)
  @disposed = false
end

Instance Method Details

#disposeObject



14
15
16
17
# File 'lib/dxruby_sdl/render_target.rb', line 14

def dispose
  @disposed = true
  @_image = nil
end

#disposed?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/dxruby_sdl/render_target.rb', line 19

def disposed?
  @disposed
end

#draw(*args) ⇒ Object



23
24
25
26
# File 'lib/dxruby_sdl/render_target.rb', line 23

def draw(*args)
  check_disposed
  @_image.draw(*args)
end

#draw_ex(x, y, image, hash = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dxruby_sdl/render_target.rb', line 28

def draw_ex(x, y, image, hash = {})
  check_disposed
  if hash[:z] && hash[:z] != 0
    raise NotImplementedError, 'Window.draw_ex(x, y, image, z: != 0)'
  end
  option = {
    angle: 0,
    scale_x: 1,
    scale_y: 1,
    center_x: 0,
    center_y: 0,
  }.merge(hash)
  SDL::Surface.transform_blit(image._surface, @_image._surface,
    option[:angle],
    option[:scale_x], option[:scale_y],
    option[:center_x], option[:center_y],
    x + option[:center_x], y + option[:center_y],
    0)
end

#draw_font(x, y, string, font, option = {}) ⇒ Object



48
49
50
51
52
# File 'lib/dxruby_sdl/render_target.rb', line 48

def draw_font(x, y, string, font, option = {})
  check_disposed
  color = option[:color] || [255, 255, 255]
  @_image.draw_font(x, y, string, font, color)
end

#to_imageObject



54
55
56
57
# File 'lib/dxruby_sdl/render_target.rb', line 54

def to_image
  check_disposed
  @_image
end