Sha256: 79517495d21d400705a4150b2993ffdcefeef30c61afd67c7c2f6a127aa9ed97

Contents?: true

Size: 836 Bytes

Versions: 43

Compression:

Stored size: 836 Bytes

Contents

def mirror_effect(target, options={})
  proc_name = options[:proc_name] || "mirror-effect"

  target.delete_post_draw_proc_by_name(proc_name)

  return if options[:uninstall]

  scale_y = 0.4
  shear_x = 0.5
  target.add_around_draw_proc(proc_name) do |canvas, x, y, w, h, simulation,
                                             next_proc|
    rx, ry, rw, rh = next_proc.call(canvas, x, y, w, h, simulation)
    unless simulation
      canvas.save_context do
        height = ry - y
        base = ry + target.margin_bottom
        canvas.translate_context(0, base)
        canvas.reflect_context(:x)
        canvas.shear_context(shear_x, 0)
        canvas.scale_context(1, scale_y)
        canvas.translate_context(0, -base)
        next_proc.call(canvas, x, y, w, height, simulation)
      end
    end
    [rx, ry, rw, rh]
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

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