Sha256: 50b90d06c6b196585cc1a22c771394bde719a82e4bd0fdcfcdcb669d096c5bd7

Contents?: true

Size: 942 Bytes

Versions: 4

Compression:

Stored size: 942 Bytes

Contents

#!/usr/bin/env ruby

require 'bundler/setup'
require 'whirled_peas'
require 'whirled_peas/animator/easing'

module WhirledPeas
  NUM_POINTS = 60

  Animator::Easing::EASING.keys.each do |func|
    Animator::Easing::EFFECTS.each do |effect|
      easing = Animator::Easing.new(func, effect)
      graph = Array.new(NUM_POINTS / ASPECT_RATIO) { '┃' }
      NUM_POINTS.times.each do |i|
        input = i.to_f / (NUM_POINTS - 1)
        eased_value = ((easing.ease(input) * NUM_POINTS * 2) / ASPECT_RATIO).floor
        graph.each.with_index do |row, row_num|
          y_value = NUM_POINTS.to_f / ASPECT_RATIO - row_num - 1
          row << if eased_value == 2 * y_value
            '▄'
          elsif eased_value == 2 * y_value + 1
            '▀'
          else
            ' '
          end
        end
      end
      graph << '┗' + '━' * NUM_POINTS
      puts "#{func} (#{effect})"
      puts graph.join("\n")
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
whirled_peas-0.11.0 bin/easing
whirled_peas-0.10.0 bin/easing
whirled_peas-0.9.1 bin/easing
whirled_peas-0.9.0 bin/easing