Пример #1
0
    def test_pantone(self):
        from Goulib.table import Table,Cell
        from Goulib.itertools2 import reshape

        t=[Cell(name,style={'background-color':pantone[name].hex}) for name in sorted(pantone)]
        t=Table(reshape(t,(0,10)))
        with open(path+'\\results\\colors.pantone.html', 'w') as f:
            f.write(t.html())
Пример #2
0
 def patches(self, wide=64, size=(16, 16)):
     """Image made of each palette color
     """
     n = len(self)
     data = itertools2.reshape(range(n), (n // wide, wide))
     res = image.Image(data, 'P', palette=self)
     res = res.scale(size)
     return res
Пример #3
0
 def patches(self,wide=64,size=(16,16)):
     """Image made of each palette color
     """
     from Goulib.image import Image
     n=len(self)
     data=itertools2.reshape(range(n),(n//wide,wide))
     res=Image(data,'P',palette=self)
     res=res.scale(size)
     return res
Пример #4
0
    def test_pantone(self):
        from Goulib.table import Table, Cell
        from Goulib.itertools2 import reshape

        t = [
            Cell(name, style={'background-color': pantone[name].hex})
            for name in sorted(pantone)
        ]
        t = Table(reshape(t, (0, 10)))
        with open(path + '\\results\\colors.pantone.html', 'w') as f:
            f.write(t.html())
Пример #5
0
def ColorTable(colors,key,width=10):
    from Goulib.table import Table, Cell
    from Goulib.itertools2 import reshape
    
    def tooltip(c):
        return '\n'.join('%s = %s'%(k,v) for k,v in c._values.items())

    labels=(color['black'],color['white']) #possible colors for labels
    t=[]
    for c in sorted(colors.values(),key=key):
        c2=nearest_color(c,labels,opt=max) #chose the label color with max difference to pantone color
        s='<span title="%s" style="color:%s">%s</span>'%(tooltip(c),c2.hex,c.name)
        t.append(Cell(s,style={'background-color':c.hex}))
    return Table(reshape(t,(0,width)))
Пример #6
0
def ColorTable(colors, key=None, width=10):
    def tooltip(c):
        return '\n'.join('%s = %s' % (k, v) for k, v in c._values.items())

    labels = (color['black'], color['white'])  # possible colors for labels
    t = []
    colors = colors.values()
    if key:
        colors = list(colors)
        colors.sort(key=key)
    for c in colors:
        # chose the label color with max difference to pantone color
        c2 = nearest_color(c, labels, opt=max)
        s = '<span title="%s" style="color:%s">%s</span>' % (tooltip(c),
                                                             c2.hex, c.name)
        t.append(Gtable.Cell(s, style={'background-color': c.hex}))
    return Gtable.Table(itertools2.reshape(t, (0, width)))