Class: Castaway::RelativeTo

Inherits:
Object
  • Object
show all
Defined in:
lib/castaway/relative_to.rb

Instance Method Summary collapse

Constructor Details

#initialize(image_file_name, production) ⇒ RelativeTo

Returns a new instance of RelativeTo.



6
7
8
9
10
11
12
# File 'lib/castaway/relative_to.rb', line 6

def initialize(image_file_name, production)
  path = production.resource(image_file_name)
  image = MiniMagick::Image.new(path)
  @width = image.width.to_f
  @height = image.height.to_f
  @production = production
end

Instance Method Details

#position(x, y) ⇒ Object



14
15
16
# File 'lib/castaway/relative_to.rb', line 14

def position(x, y)
  Castaway::Point.new(x / @width, y / @height) * @production.resolution
end