Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions gradify.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def __init__(self, black_sensitivity=4.3, white_sensitivity = 3, num_colors=4, r
self.pairs = []

self.num_done = 0

self.indent = ' '

if webkit_only:
self.BROWSER_PREFIXES= ["-webkit-"]
Expand All @@ -50,6 +52,9 @@ def __init__(self, black_sensitivity=4.3, white_sensitivity = 3, num_colors=4, r
}
self.init_CLI_args()

if not self.args.human_readable:
self.indent = ''

if self.args.demo:
self.demo_file = "demo.html"
open(self.demo_file, "w").close()
Expand All @@ -76,6 +81,7 @@ def init_CLI_args(self):
self.parser.add_argument("-f", "--file", help="Gradify single file")
self.parser.add_argument("-c", "--classname", help="Specific classname of CSS to add gradients to (default is 'gradify')")
self.parser.add_argument("--demo", help="Create example HTML file displaying results, opens when completed", action="store_true")
self.parser.add_argument("--human-readable", help="Cook human readable css", action="store_true")
self.args = self.parser.parse_args()
return

Expand Down Expand Up @@ -174,16 +180,16 @@ def printRules(self):
print(".%s-%d {" % (self.args.classname, pair[0]))
else:
print(".gradify-%d {" % (pair[0]))
print("background:")
print(self.indent + "background:")
if self.args.single:
print "rgb(" + str(pair[1][0])+"," + str(pair[1][1]) +"," + str(pair[1][2]) +");"
else:
print "rgb(" + str(pair[1][0][0])+"," + str(pair[1][0][1]) +"," + str(pair[1][0][2]) +");"
if not self.args.single:
print("background:")
print(self.indent + "background:\n")
for prefix in self.BROWSER_PREFIXES:
for color in pair[1]:
print prefix + "linear-gradient("+str(color[3])+"deg, rgba(" + str(color[0])+"," + str(color[1]) +"," + str(color[2]) +","+str(1)+") 0%, rgba(" + str(color[0])+"," + str(color[1]) +"," + str(color[2]) +",0) 100%)"
print self.indent + self.indent + prefix + "linear-gradient("+str(color[3])+"deg, rgba(" + str(color[0])+"," + str(color[1]) +"," + str(color[2]) +","+str(1)+") 0%, rgba(" + str(color[0])+"," + str(color[1]) +"," + str(color[2]) +",0) 100%)"
i += 1
if i==self.MAX_COLORS:
print ";"
Expand Down