Class: Castaway::Element::Pointer

Inherits:
Still
  • Object
show all
Defined in:
lib/castaway/element/pointer.rb

Instance Attribute Summary

Attributes inherited from Still

#filename, #info

Attributes inherited from Base

#attributes, #production, #scene, #size

Instance Method Summary collapse

Methods inherited from Still

#_prepare_canvas

Methods inherited from Base

#_absolute, #_composite, #_convert, #_evaluate_animation_list, #_evaluate_attributes!, #_transform, #alive_at?, #animate, #at, #attribute, #duration, #effect, #enter, #exit, #gravity, #in, #out, #path, #render_at, #rotate, #scale, #t1, #t2, #tail

Constructor Details

#initialize(production, scene, id) ⇒ Pointer

Returns a new instance of Pointer.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/castaway/element/pointer.rb', line 9

def initialize(production, scene, id)
  path, options = production.pointers.fetch(id)
  super(production, scene, path)

  @box = Box.from_size(@size)
  @box[:hotspot] = Castaway::Point.make(options[:hotspot] || [0, 0])

  ideal_width = production.resolution.width * options[:scale]
  sx = ideal_width.to_f / @size.width

  scale(sx)
end

Instance Method Details

#hotspotObject



22
23
24
25
26
27
# File 'lib/castaway/element/pointer.rb', line 22

def hotspot
  @box.
    scale(@scale || 0).
    rotate(@angle || 0).
    bounds[:hotspot]
end

#positionObject



29
30
31
# File 'lib/castaway/element/pointer.rb', line 29

def position
  @position - hotspot
end