Class: Image

Inherits:
Object
  • Object
show all
Extended by:
Log
Defined in:
lib/fantasy/image.rb

Constant Summary collapse

@@images =
{}

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Log

log

Constructor Details

#initialize(image_name) ⇒ Image

Returns a new instance of Image.



4
5
6
# File 'lib/fantasy/image.rb', line 4

def initialize(image_name)
  @image = Image.load(image_name)
end

Class Method Details

.load(image_name) ⇒ Object



25
26
27
# File 'lib/fantasy/image.rb', line 25

def load(image_name)
  locate_image(image_name)
end

.preload_imagesObject



29
30
31
32
33
34
35
# File 'lib/fantasy/image.rb', line 29

def preload_images
  return unless Dir.exist?(base_path)

  Dir.each_child(base_path) do |file_name|
    locate_image(file_name) unless file_name.start_with?(".")
  end
end

Instance Method Details

#draw(x:, y:, scale: 1) ⇒ Object



8
9
10
# File 'lib/fantasy/image.rb', line 8

def draw(x:, y:, scale: 1)
  @image.draw(x, y, 0, scale, scale)
end

#heightObject



16
17
18
# File 'lib/fantasy/image.rb', line 16

def height
  @image.height
end

#widthObject



12
13
14
# File 'lib/fantasy/image.rb', line 12

def width
  @image.width
end