Skip to content

Instantly share code, notes, and snippets.

@jpoz
Created July 28, 2009 17:03
Show Gist options
  • Select an option

  • Save jpoz/157538 to your computer and use it in GitHub Desktop.

Select an option

Save jpoz/157538 to your computer and use it in GitHub Desktop.
get %r{^/(\d{1,3})/(\d{1,3})/([0-9A-Fa-f]{6,6})/([0-9A-Fa-f]{6,6})/output.(\w+)$} do |height, width, color1, color2, type|
case type
when "png"
headers 'Content-Type' => 'image/png'
png_gradient = PNGGradient.new(width.to_i, height.to_i, "##{color1}", "##{color2}")
png_gradient.to_blob()
when "html"
@height, @width, @color1, @color2 = height, width, color1, color2
haml :png, :layout => false
else
haml :'404'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment