Class: DYI::Animation::Base
Abstract
- Inherits:
-
Object
- Object
- DYI::Animation::Base
show all
- Defined in:
- lib/dyi/animation.rb
Overview
Base class for animation classes.
Constant Summary
collapse
- IMPLEMENT_ATTRIBUTES =
[:from, :to, :duration, :begin_offset,
:begin_event, :end_offset, :end_event, :fill,
:additive, :restart, :relays, :relay_times,
:calc_mode, :repeat_count, :key_splines]
- VALID_VALUES =
{
:fill => ['freeze','remove'],
:additive => ['replace', 'sum'],
:restart => ['always', 'whenNotActive', 'never'],
:calc_mode => ['discrete', 'linear', 'paced', 'spline']
}
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(shape, options) ⇒ Base
Returns a new instance of Base.
194
195
196
197
198
199
200
201
202
203
204
|
# File 'lib/dyi/animation.rb', line 194
def initialize(shape, options)
raise ArgumentError, "`:to' option is required" unless options.key?(:to)
@shape = shape
options.each do |attr, value|
if IMPLEMENT_ATTRIBUTES.include?(attr.to_sym)
__send__("#{attr}=", value)
end
end
@relays ||= []
@relay_times ||= []
end
|
Instance Attribute Details
#additive=(value) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/dyi/animation.rb', line 132
VALID_VALUES.each do |attr, valid_values|
define_method("#{attr.to_s}=") {|value|
if (value = value.to_s).size == 0
instance_variable_set("@#{attr}", nil)
else
unless VALID_VALUES[attr].include?(value)
raise ArgumentError, "`#{value}' is invalid #{attr}"
end
instance_variable_set("@#{attr}", value)
end
}
end
|
#calc_mode=(value) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/dyi/animation.rb', line 132
VALID_VALUES.each do |attr, valid_values|
define_method("#{attr.to_s}=") {|value|
if (value = value.to_s).size == 0
instance_variable_set("@#{attr}", nil)
else
unless VALID_VALUES[attr].include?(value)
raise ArgumentError, "`#{value}' is invalid #{attr}"
end
instance_variable_set("@#{attr}", value)
end
}
end
|
#fill=(value) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/dyi/animation.rb', line 132
VALID_VALUES.each do |attr, valid_values|
define_method("#{attr.to_s}=") {|value|
if (value = value.to_s).size == 0
instance_variable_set("@#{attr}", nil)
else
unless VALID_VALUES[attr].include?(value)
raise ArgumentError, "`#{value}' is invalid #{attr}"
end
instance_variable_set("@#{attr}", value)
end
}
end
|
#key_splines=(value) ⇒ Object
182
183
184
|
# File 'lib/dyi/animation.rb', line 182
def key_splines=(keys)
@key_splines = keys.map{|time| time.to_f}
end
|
#relays=(value) ⇒ Object
175
176
177
|
# File 'lib/dyi/animation.rb', line 175
def relay_times=(times)
@relay_times = times.map{|time| time.to_f}
end
|
#repeat_count=(value) ⇒ Object
152
153
154
|
# File 'lib/dyi/animation.rb', line 152
def repeat_count=(count)
@repeat_count = count.to_f
end
|
#restart=(value) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/dyi/animation.rb', line 132
VALID_VALUES.each do |attr, valid_values|
define_method("#{attr.to_s}=") {|value|
if (value = value.to_s).size == 0
instance_variable_set("@#{attr}", nil)
else
unless VALID_VALUES[attr].include?(value)
raise ArgumentError, "`#{value}' is invalid #{attr}"
end
instance_variable_set("@#{attr}", value)
end
}
end
|
Instance Method Details
#accumulate=(value) ⇒ Object
188
189
190
|
# File 'lib/dyi/animation.rb', line 188
def accumulate=(value)
@accumulate = value
end
|
#accumulate? ⇒ Boolean
Returns whether the animation is cumulative.
116
117
118
|
# File 'lib/dyi/animation.rb', line 116
def accumulate?
@accumulate ? true : false
end
|
#begin_event=(event) ⇒ Object
160
161
162
|
# File 'lib/dyi/animation.rb', line 160
def begin_event=(event)
@begin_event = event
end
|
#begin_offset=(offset) ⇒ Object
156
157
158
|
# File 'lib/dyi/animation.rb', line 156
def begin_offset=(offset)
@begin_offset = offset.to_f
end
|
#duration=(duration) ⇒ Object
145
146
147
|
# File 'lib/dyi/animation.rb', line 145
def duration=(duration)
@duration = duration.to_f
end
|
#end_event=(event) ⇒ Object
168
169
170
|
# File 'lib/dyi/animation.rb', line 168
def end_event=(event)
@end_event = event
end
|
#end_offset=(offset) ⇒ Object
164
165
166
|
# File 'lib/dyi/animation.rb', line 164
def end_offset=(offset)
@end_offset = offset.to_f
end
|
#relay_times=(times) ⇒ Object
175
176
177
|
# File 'lib/dyi/animation.rb', line 175
def relay_times=(times)
@relay_times = times.map{|time| time.to_f}
end
|