Skip to content

Instantly share code, notes, and snippets.

@baskerville
Created November 21, 2011 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baskerville/1382722 to your computer and use it in GitHub Desktop.
Save baskerville/1382722 to your computer and use it in GitHub Desktop.
Triadic Color Scheme Generation
#! /usr/bin/python
import sys
from grapefruit import Color
BRIGHT_LUM = 80
DARK_LUM = 60
def main():
args = sys.argv[1:]
if len(args) > 0:
arg = args[0]
c1 = Color.NewFromHtml(arg)
c2, c3 = c1.TriadicScheme(120, 'rgb')
for c in [c1, c2, c3]:
(L, a, b) = c.lab
bc = Color.NewFromLab(BRIGHT_LUM, a, b)
dc = Color.NewFromLab(DARK_LUM, a, b)
print(bc.html.upper())
print(dc.html.upper())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment