Sha256: 7293d9938c58d1cabdb9669e7ed19670d062e9f905146fce3aa6383270b33e2d

Contents?: true

Size: 682 Bytes

Versions: 4

Compression:

Stored size: 682 Bytes

Contents

require 'rubygems'
require 'interpolate'
require 'pp'


# a non-linear set of 2D vertexes;
# the shape changes at each frame
time_frames = {
  0 => [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]], # a horizontal line
  1 => [[0, 0], [1, 0], [3, 0], [0, 4], [0, 0]], # a triangle
  2 => [[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]], # a square
  3 => [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]], # a horizontal line, again
  4 => [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]]  # a vertical line
}


paths = Interpolation.new(time_frames)

# show the vertex positions in time increments of 0.25
(0).step(4, 0.25) do |time|
  points = paths.at(time)
  puts ">> At #{time}s, points are:"
  p points
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
interpolate-0.2.3 examples/nested.rb
interpolate-0.2.1 examples/nested.rb
interpolate-0.2.0 examples/nested.rb
interpolate-0.2.2 examples/nested.rb