Sha256: 5b9293faab03d5e88142ba768e4a8461439ce16a99b52869f62f69f867569f18

Contents?: true

Size: 1.44 KB

Versions: 43

Compression:

Stored size: 1.44 KB

Contents

def setup_rotate_zoom_effect_slide(slide)
  class << slide
    def rotate_zoom_effect
      angle = 0
      last_angle = 360
      last_scale_x = 1
      last_scale_y = 1
      idle_id = nil
      effected = false
      add_around_draw_proc do |canvas, x, y, w, h, simulation, next_proc|
        canvas.save_context do
          if !simulation and !effected
            angle = [angle + last_angle * 0.05, last_angle].min
            ratio = angle / last_angle
            scale_x = last_scale_x * ratio
            scale_y = last_scale_y * ratio
            translate(canvas, angle, scale_x, scale_y)
            idle_id ||= Gtk.idle_add do
              continue = (angle != last_angle and
                          canvas.current_slide == self)
              unless continue
                idle_id = nil
                effected = true
              end
              canvas.activate("Redraw")
              continue
            end
          end
          next_proc.call(canvas, x, y, w, h, simulation)
        end
      end
    end

    private
    def translate(canvas, angle, scale_x, scale_y)
      center_x = canvas.width / 2
      center_y = canvas.height / 2
      canvas.translate_context(center_x, center_y)
      canvas.rotate_context(angle)
      canvas.translate_context(-center_x, -center_y)
      canvas.scale_context(scale_x, scale_y)
    end
  end
end


match(Slide) do |slides|
  slides.each do |slide|
    setup_rotate_zoom_effect_slide(slide)
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
rabbit-3.0.3 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-3.0.2 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-3.0.1 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-3.0.0 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.2.1 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.2.0 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.9 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.8 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.7 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.6 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.5 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.4 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.3 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.2 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.1 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.1.0 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.0.9 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.0.8 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.0.7 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb
rabbit-2.0.6 lib/rabbit/theme/rotate-zoom-effect/rotate-zoom-effect.rb