Skip to content
Merged
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
15 changes: 15 additions & 0 deletions pywal/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ def darken(self, percent):
percent = float(re.sub(r"[\D\.]", "", str(percent)))
return Color(darken_color(self.hex_color, percent / 100))

def foxify(self, amount):
"""Foxify color by amount."""
return Color(foxify_color(self.hex_color, amount))

def saturate(self, percent):
"""Saturate a color."""
percent = float(re.sub(r"[\D\.]", "", str(percent)))
Expand Down Expand Up @@ -310,6 +314,17 @@ def lighten_color(color, amount):
return rgb_to_hex(color)


def foxify_color(color, f):
"""pywalfox algorithm to lighten colors"""
pwf = float(f)
c = hex_to_rgb(color)
b = []
b.append(min((max(0, int(c[0] + (c[0] * pwf)))), 255))
b.append(min((max(0, int(c[1] + (c[1] * pwf)))), 255))
b.append(min((max(0, int(c[2] + (c[2] * pwf)))), 255))
return rgb_to_hex(b)


def alpha_integrify(alpha_value):
"""
ensure the alpha string is an int between 0 and 100
Expand Down