Class: Teaas::Parrotify
- Inherits:
-
Object
- Object
- Teaas::Parrotify
- Defined in:
- lib/teaas/parrotify.rb
Constant Summary collapse
- OFFSETS =
[ {:x_offset => 1, :y_offset => 1}, {:x_offset => 0.8857, :y_offset => 0.98}, {:x_offset => 0.7714, :y_offset => 0.98}, {:x_offset => 0.6857, :y_offset => 1.02}, {:x_offset => 0.6571, :y_offset => 1.04}, {:x_offset => 0.7428, :y_offset => 1.08}, {:x_offset => 0.8571, :y_offset => 1.12}, {:x_offset => 0.9714, :y_offset => 1.12}, {:x_offset => 1.0571, :y_offset => 1.1}, {:x_offset => 1.0857, :y_offset => 1.08} ]
Class Method Summary collapse
-
.parrotify(original_img) ⇒ Magick::ImageList
Best when used with Turboize.turbo to generate multiple intense speeds.
-
.parrotify_from_file(path) ⇒ Magick::ImageList
Best when used with Turboize.turbo to generate multiple intense speeds.
Class Method Details
.parrotify(original_img) ⇒ Magick::ImageList
Best when used with Turboize.turbo to generate multiple intense speeds.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/teaas/parrotify.rb', line 21 def self.parrotify(original_img) parrotify_image = Magick::ImageList.new img = Teaas::Helper.prepare_for_animation(original_img) width = img.columns height = img.rows final_img = Magick::Image.new(width, height) final_img.format = "gif" parrotify_image = Magick::ImageList.new OFFSETS.each do |o| x_coord = width * (1 - o[:x_offset]) y_coord = (height * (1 - o[:y_offset])) + (0.3 * height) parrotify_image << final_img.composite(img, x_coord, y_coord, Magick::OverCompositeOp) end parrotify_image end |
.parrotify_from_file(path) ⇒ Magick::ImageList
Best when used with Turboize.turbo to generate multiple intense speeds. Wrapper around parrotify
43 44 45 46 47 |
# File 'lib/teaas/parrotify.rb', line 43 def self.parrotify_from_file(path) img = Magick::Image.read(path) parrotify(img) end |