Class: ThemesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/themes_controller.rb

Instance Method Summary collapse

Instance Method Details

#switchObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/themes_controller.rb', line 4

def switch
  if params[:image_url]
    @url = params[:image_url]
    begin
      extr = Prizm::Extractor.new(@url)
      @colors = extr.get_colors(7, false).sort { |a, b| b.to_hsla[2] <=> a.to_hsla[2] }.map { |p| extr.to_hex(p) }
      extr = nil
    rescue
      @colors = []
    end

    write_css
  end
end