colors.py
colors.py copied to clipboard
Blendmode didn't work correctly in Python 3.6
h = hex('54a050').overlay(rgb(76, 83, 10)).hex
print(h)
produced this error:
Traceback (most recent call last):
File "testing.py", line 18, in <module>
h = rgb('768310').hex
File "/Library/Python/2.7/site-packages/colors/base.py", line 194, in __init__
raise ValueError('Color values must be between 0 and 255')
ValueError: Color values must be between 0 and 255
It worked fine in Python 2.7.10
It looks like you’re just using it wrong? Unless I’m misunderstanding.
rgb('768310')
isn’t the right input for rgb()
at all.
And also, you say 3.6, but your stacktrace is 2.7.
Thank you for getting back to me. I tried it again making sure I'm using Python 3.
Traceback (most recent call last):
File "testing.py", line 24, in <module>
h = hex('54a050').overlay(rgb(76, 83, 10)).hex
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/colors/base.py", line 114, in overlay
return self.screen(self.multiply(other))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/colors/base.py", line 53, in multiply
self_rgb.red * other_rgb.red / 255.0,
AttributeError: 'RGBColor' object has no attribute 'red'
I also don't see any instance of me typing rgb('768310'). I have separated those out clearly into integers with commas as the code shows.
Ok, that looks like a better stacktrace. This is because of the way I'm using metaclasses which have changed for python3. Are you willing to submit a PR? If not, I can try it out this weekend. I'm not a python3 user myself yet. :(
Let me put it this way:
Uh, what's a metaclass?