Beispiel #1
0
def showOff(colors,bgcols):
  color.parrot("color1.htf")
  print "<p>Foreground colors being tried: "
  for c in colors:
    print "%s " % (c),
  print "</p><p>Backgrounds used for comparison: "
  for b in bgcols:
    print "%s " % (b),
  print "</p>"
  print "<table>"
  (cM,cG) = color.contLevels('n')
  for i in bgcols:
    print "<tr>"
    a = ''
    for j in colors:
      nratio = gridLums(i,j)
      if (nratio >= cG):
        a = 'cgood'
      elif (nratio >= cM):
        a = 'cmin'
      elif (i == j):
        a = 'cnone'
      else:
        a = 'cbad'
      print "<td class=\"{bang}\" style=\"color: #{one}; background-color: #{two};\">#{one}/#{two}</td>".format(one = j,two = i,bang = a)
    print "</tr>"
  print "</table>"
  if len(bgcols) > 1:
    cf = findCommon(bgcols)
    print "<p>Common foregrounds:</p>" # ??? May have messed this up somehow. Don't remember its original intent.
    cf = magicSort(cf,bgcols[0]) # Um, I guess sorted based on contrast with first given background? I should have documented this better.
    for fc in cf:
      print "<div class=\"holder\">"
      for bc in bgcols:
        (k1,k2) = sorted([str(bc).upper(),str(fc)])
        ratio = ''
        try:
          ratio = lumlib[k1][k2]
        except KeyError as e:
          ratio = gridLums(k1,k2)
          break
        if (ratio >= cG):
          a = ''
        elif (ratio >= cM):
          a = ' cmin'
        elif (fc == bc):
          a = ' cnone'
        else:
          a = ' cbad'
        print "<span class=\"comfg{con}\" style=\"font-family: monospace; color: #{fg}; background-color: #{bg};\"> {fg}/{bg}: {rat} </span>".format(fg = fc,bg = bc,rat = ratio,con = a)
      print "</div>"
  print "<p class=\"clr\">Size of grid: %i</p>" % len(lumlib)
  color.parrot("color2.htf")
  color.savelumlib()
  return 0
Beispiel #2
0
def storeGrid():
#  for x in sorted(lumlib.keys()):
#    print "%s: %s " % (x,lumlib[x])
  print "Grid size %i" % len(lumlib)
  color.savelumlib()