Skip to content

Instantly share code, notes, and snippets.

@patrick99e99
Created January 3, 2009 01:37
Show Gist options
  • Save patrick99e99/42766 to your computer and use it in GitHub Desktop.
Save patrick99e99/42766 to your computer and use it in GitHub Desktop.
require 'polaroid.rb'
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.1.0 application starting on http://0.0.0.0:3000
=> Debugger enabled
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:278:in `load_missing_constant': uninitialized constant Fleximage (NameError)
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing'
from /Users/patrick/coding/rails/matthew/lib/polaroid.rb:1
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
... 31 levels...
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from ./script/server:3
class Fleximage::Operator::Polaroid < Fleximage::Operator::Base
def operate(angle)
@image.border!(18, 18, "#f0f0ff")
# Bend the image
@image.background_color = "none"
amplitude = @image.columns * 0.01 # vary according to taste
wavelength = @image.rows * 2
@image.rotate!(90)
@image = @image.wave(amplitude, wavelength)
@image.rotate!(-90)
# Make the shadow
shadow = @image.flop
shadow = shadow.colorize(1, 1, 1, "gray75") # shadow color can vary to taste
shadow.background_color = "white" # was "none"
shadow.border!(10, 10, "white")
shadow = shadow.blur_image(0, 3) # shadow blurriness can vary according to taste
# Composite image over shadow. The y-axis adjustment can vary according to taste.
@image = shadow.composite(@image, -amplitude/2, 5, Magick::OverCompositeOp)
@image.rotate!(angle) # vary according to taste
@image.trim!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment