Class: PointInTime
- Inherits:
-
Object
- Object
- PointInTime
- Defined in:
- lib/ip-world-map/point_in_time.rb
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
- #age ⇒ Object
-
#initialize(x, y, initial_opacity, lifetime) ⇒ PointInTime
constructor
A new instance of PointInTime.
- #opacity ⇒ Object
- #opacity_in_time(time) ⇒ Object
Constructor Details
#initialize(x, y, initial_opacity, lifetime) ⇒ PointInTime
Returns a new instance of PointInTime.
4 5 6 7 8 |
# File 'lib/ip-world-map/point_in_time.rb', line 4 def initialize x, y, initial_opacity, lifetime @x, @y = x, y @time = 0 @decay = Decay.new(initial_opacity, lifetime) end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
2 3 4 |
# File 'lib/ip-world-map/point_in_time.rb', line 2 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
2 3 4 |
# File 'lib/ip-world-map/point_in_time.rb', line 2 def y @y end |
Instance Method Details
#age ⇒ Object
19 20 21 |
# File 'lib/ip-world-map/point_in_time.rb', line 19 def age @time += 1 end |
#opacity ⇒ Object
15 16 17 |
# File 'lib/ip-world-map/point_in_time.rb', line 15 def opacity @decay.value(@time) end |
#opacity_in_time(time) ⇒ Object
10 11 12 13 |
# File 'lib/ip-world-map/point_in_time.rb', line 10 def opacity_in_time time @time = time if time opacity end |