Esempio n. 1
0
def config_colors(col_source, col_params):

    # get palette from matplotlib
    if col_source == 'matplotlib':
        try:
            num_col = col_params['col_num']
            step = 256 / num_col
            cmap = cm.get_cmap(col_params['cmap'], 256)
            colors = 255 * cmap(np.arange(0, 256, step))[:,:-1]
            colors = colors.astype(int)
        except ValueError:
            print 'Colormap not recognized -- using default color scheme'
            colors = [[0, 255, 255], [128, 128, 255], [255, 0, 255], [255, 128, 128]]
            colors = np.array(colors)

    # get palette from www.colourlovers.com
    elif col_source == 'colourlovers':
            cl = ColourLovers()
            palette = cl.palettes(**col_params)[0]
            colors = palette.colours
            for i in range(len(colors)):
                colors[i] = hex_to_rgb(colors[i])
            colors = np.array(colors)
    else:
        print 'Color source not recognized -- using default color scheme'
        colors = [[0, 255, 255], [128, 128, 255], [255, 0, 255], [255, 128, 128]]
        colors = np.array(colors)

    return colors
Esempio n. 2
0
def config_colors(col_source, col_params):

    # get palette from matplotlib
    if col_source == 'matplotlib':
        try:
            num_col = col_params['col_num']
            step = 256 / num_col
            cmap = cm.get_cmap(col_params['cmap'], 256)
            colors = 255 * cmap(np.arange(0, 256, step))[:, :-1]
            colors = colors.astype(int)
        except ValueError:
            print 'Colormap not recognized -- using default color scheme'
            colors = [[0, 255, 255], [128, 128, 255], [255, 0, 255],
                      [255, 128, 128]]
            colors = np.array(colors)

    # get palette from www.colourlovers.com
    elif col_source == 'colourlovers':
        cl = ColourLovers()
        palette = cl.palettes(**col_params)[0]
        colors = palette.colours
        for i in range(len(colors)):
            colors[i] = hex_to_rgb(colors[i])
        colors = np.array(colors)
    else:
        print 'Color source not recognized -- using default color scheme'
        colors = [[0, 255, 255], [128, 128, 255], [255, 0, 255],
                  [255, 128, 128]]
        colors = np.array(colors)

    return colors
def home():
    # get a random palette
    cl = ColourLovers()
    palette = cl.palettes('random').pop()
    palette_id, palette_title, colours = palette.id, palette.title, palette.colours

    return render_template('mockup.html', **{
        'colour1': get_colour(colours, 0),
        'colour2': get_colour(colours, 1),
        'colour3': get_colour(colours, 2),
        'colour4': get_colour(colours, 3),
        'colour5': get_colour(colours, 4),
        'palette_id': palette_id,
        'palette_title': palette_title,
        'mtime': str(os.path.getmtime(app.root_path + '/static/style.css'))
    })
Esempio n. 4
0
 def _on_query(self):
     cl = ColourLovers()
     query_type = self._get_query_type()
     username = self.username.text()
     keywords = self.keywords.text()
     hue_idx = self.hue_option.currentIndex()
     hue = self.hue_option.itemData(hue_idx)
     opts = {}
     if username:
         opts['lover'] = username
     if keywords:
         opts['keywords'] = keywords
     if hue:
         opts['hueOption'] = str(hue.toString())
     print opts
     palettes = cl.palettes(query_type, **opts)
     self.table.set_palettes(palettes)
Esempio n. 5
0
from colourlovers import ColourLovers

cl = ColourLovers()
print(cl.palettes('top'))