Compare commits
No commits in common. "1287b93ef4cfdfd16dce1028eaf703569cc5e7b5" and "561544ffa2acdc7220633fad6470adc1fa452580" have entirely different histories.
1287b93ef4
...
561544ffa2
Binary file not shown.
@ -3,6 +3,6 @@ It makes base16 schemes. Pass a background color, an accent color, and optionall
|
||||
|
||||
Color arguments are in the form of "hue,sat,lum" for background and "hue,sat" for the other two. All values must be numbers between 0.0 and 1.0 (you're welcome to try other values, just don't be shocked if it breaks). Also, keep in mind that luminance here is *relative* luminance, or the color's brightness as perceived by the human eye. This is different from the usual HSL space.
|
||||
|
||||
The script will do its best to make sure everything is readable. It tries to keep a contrast ratio of 7:1 between the foreground and background colors, while trying to stay above 3:1 between foreground and highlight, the "rainbow" colors (i.e. the last 8 colors) and highlight, and the "dark" foreground and background. Usually it does a good job. But it tends not to like a background luminance that hovers around 0.3, that's when stuff gets to be an eyesore.
|
||||
The script will do its best to make sure everything is readable. It tries to keep a contrast ratio of 7:1 between the foreground and background colors, while trying to stay above 3:1 between foreground and highlight, the "rainbow" colors (i.e. the last 8 colors) and highlight, and the "dark" foreground and background. Usually it does a good job. But it tends not to like a background luminance that hovers in the middle, that's when stuff gets to be an eyesore. Keep your background close to 1.0 or 0.0, that's when it looks okay.
|
||||
|
||||
For the last 8 colors, you can make them blend with the background hue by passing `-r (amount)`, the amount being between 0.0 and 1.0. 0.0 means no blending, 1.0 makes them all the same hue.
|
||||
For the last 8 colors, you can make them blend with the background hue by passing `-r (amount)`, the amount being between 0.0 and 1.0. 0.0 is no blending, 1.0 makes them all the same hue.
|
||||
|
32
acid16.py
32
acid16.py
@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import colorsys, optparse
|
||||
import colorsys, optparse, collections
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
parser = optparse.OptionParser(usage="usage: %prog [options] background accent [foreground]")
|
||||
@ -45,9 +45,6 @@ except:
|
||||
def lerp(a, b, t):
|
||||
return a + (b - a) * t
|
||||
|
||||
def reposition(a, b, t, c, d):
|
||||
return lerp(c, d, (t - a) / (b - a))
|
||||
|
||||
def mixColors(a, b, t):
|
||||
return tuple(lerp(a[i], b[i], t) for i in range(3))
|
||||
|
||||
@ -96,17 +93,11 @@ lastTwo = [lerp(foreLum, 1.0 if foreLum > bgLum else 0.0, (x + 1) / 3) for x in
|
||||
foreLight = makeColor(foreHue, lastTwo[0], foreSat)
|
||||
backLight = makeColor(bgHue, lastTwo[1], bgSat)
|
||||
|
||||
rainHues = [0, 20, 60, 120, 180, 240, 300, 20]
|
||||
rainHues = [0, 20, 55, 120, 180, 240, 280, 330]
|
||||
|
||||
backFull = colorsys.hls_to_rgb(bgHue, 0.5, bgSat)
|
||||
|
||||
rainbow = [mixColors(colorsys.hls_to_rgb(hue/360.0, 0.5, 1.0), backFull, rainbowBlend) for hue in rainHues]
|
||||
|
||||
rainLums = [luminance(col) for col in rainbow]
|
||||
hiLum, loLum = max(rainLums), min(rainLums)
|
||||
minLum, maxLum = sorted((getContrast(bgLum, 4), getContrast(bgLum, 6)))
|
||||
|
||||
rainHLS = [colorsys.rgb_to_hls(*col) for col in rainbow]
|
||||
rainbow = [makeColor(rainHLS[c][0], reposition(loLum, hiLum+0.00001, rainLums[c], minLum, maxLum) if c < 7 else minLum, rainHLS[c][2]) for c in range(len(rainbow))]
|
||||
rainbow = [makeColor(colorsys.rgb_to_hls(*col)[0], getContrast(bgLum, 3.5), 1.0) for col in rainbow]
|
||||
|
||||
cols = [background, backLighter, accent, comment, foreDark, foreground, foreLight, backLight] + rainbow
|
||||
|
||||
@ -117,25 +108,22 @@ for i in range(len(cols)):
|
||||
print("base{:02X}: \"{}\"".format(i, toHex(cols[i])))
|
||||
|
||||
if options.showPreview:
|
||||
font = ImageFont.truetype("LiberationMono-Regular.ttf", 20)
|
||||
h, w = imSize = (640, 640)
|
||||
font = ImageFont.truetype("/usr/share/fonts/TTF/LiberationMono-Regular.ttf", 20)
|
||||
|
||||
im = Image.new("RGB", (640, 640), usable(background))
|
||||
draw = ImageDraw.Draw(im)
|
||||
desc = lambda t, a, b: "{} (contrast {:.1f}:1)".format(t, contrast(luminance(a), luminance(b)))
|
||||
text = lambda x, y, t, col, other: draw.text((x, y), desc(t, col, other), usable(col), font)
|
||||
|
||||
draw.rectangle((2, 2, 638, 32), usable(accent))
|
||||
text(5, 5, "Foreground on highlight", foreground, accent)
|
||||
text(5, 45, "Foreground on background", foreground, background)
|
||||
text(5, 85, "# Comment color", comment, background)
|
||||
draw.text((5, 5), "Foreground (contrast {:.1f}:1 w/ highlight)".format(contrast(luminance(foreground), luminance(accent))), usable(foreground), font)
|
||||
draw.text((5, 45), "Foreground (contrast {:.1f}:1 w/ background)".format(contrast(luminance(foreground), luminance(background))), usable(foreground), font)
|
||||
draw.text((5, 85), "# Comment color (contrast {:.1f}:1)".format(contrast(luminance(comment), luminance(background))), usable(comment), font)
|
||||
|
||||
for i in range(len(rainbow)):
|
||||
draw.rectangle((4, 120+i*40, 84, 150+i*40), usable(rainbow[i]))
|
||||
text(90, 125+i*40, "Colored text", rainbow[i], background)
|
||||
draw.text((90, 125+i*40), "Text (contrast 3.5:1)".format(contrast(luminance(rainbow[i]), luminance(background))), usable(rainbow[i]), font)
|
||||
|
||||
draw.rectangle((0, 560, 640, 600), usable(backLighter))
|
||||
text(5, 565, "'Dark' foreground", foreDark, backLighter)
|
||||
draw.text((5, 565), "'Dark' foreground (contrast {:.2f}:1)".format(contrast(luminance(backLighter), luminance(foreDark))), usable(foreDark), font)
|
||||
draw.line((0, 598, 640, 598), usable(foreground), 2)
|
||||
|
||||
for i in range(len(cols)):
|
||||
|
Loading…
Reference in New Issue
Block a user