Class: Java::javafx::animation::Timeline

Inherits:
Object
  • Object
show all
Extended by:
JRubyFX::Utils::CommonConverters
Defined in:
lib/jrubyfx/core_ext/timeline.rb

Overview

JRubyFX DSL extensions for JavaFX animation Timelines

Constant Summary

Constants included from JRubyFX::Utils::CommonConverters

JRubyFX::Utils::CommonConverters::ARG_CONVERTER_SUFFIX, JRubyFX::Utils::CommonConverters::CONVERTERS, JRubyFX::Utils::CommonConverters::ENUM_CACHE, JRubyFX::Utils::CommonConverters::ENUM_OVERRIDES, JRubyFX::Utils::CommonConverters::NAME_TO_COLORS

Instance Method Summary collapse

Methods included from JRubyFX::Utils::CommonConverters

animation_converter_for, convert_args, converter_for, enum_converter, map_converter, map_enums, parse_ruby_symbols, set_overrides_for

Instance Method Details

#animate(prop, args) ⇒ Object

call-seq:

animate myProperty, from_duration => to_duration, start_value => next_value
animate myProperty, from_duration => [with_duration, ..., to_duration], start_value => [next_value, ...]

Animates a given JavaFX property over the given duration, using the given values as keyFrames

Examples

animate translateXProperty, 0.sec => [100.ms, 1.sec], 0 => [500, 200]
animate translateYProperty, 0.sec => 1.sec, 0 => 200


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/jrubyfx/core_ext/timeline.rb', line 36

def animate(prop, args)
  time = []
  values = []
  # detect our time
  args.each do |key, value|
    if key.is_a? Duration
      time << [key, value]
      time.flatten!
    else #assume values
      values << [key, value]
      values.flatten!
    end
  end
  # add the keyframes
  [time.length, values.length].min.times do |i|
    key_frame(time[i], key_value(prop, values[i]))
  end
end