vaab / colour

Python color representations manipulation library (RGB, HSL, web, ...)
BSD 2-Clause "Simplified" License
319 stars 41 forks source link

Added invert attribute, fixes #17 #21

Closed tommilligan closed 7 years ago

tommilligan commented 8 years ago

Added invert attribute to the Color class. All current colour atributes are supported (I think). Hue is rotated x+0.5, all other attributes are 1-x type inversion.

Takes one argument (the attribute to invert), toabi I agree it's a bit more complex but I'd prefer to be at least able to choose hue, rgb or hsl to invert, if not every attribute.

Usage:

c = Color('orange')
c.invert('rgb')
c.invert('hsl')
c.invert('hex') # Inverts using rgb
c.invert('red') # etc. etc.

New attribute inversions can be supported by adding to the dictionary/lists just after attribute declaration. If attribute not recognised, ValueError will be raised.

Also wanted to say thanks vaab for a great module!

tommilligan commented 8 years ago

Have fixed syntax error in my suggestion, build is now failing due to existing work on the dev tree.

Let me know if you have any feedback!

vaab commented 8 years ago

I just looked at your code and it seems okay to me for as it is. Although for changelog and history cleanliness, I'll have to fold the 3 commits in one and reformat the summary line. There seems to be a dangling issue on travis here that might be unrelated to your code as I understand it (in the last travis build, the python 2 version would fail because of PyPI being not responsive, but the python 3 build was not trivial and might be unrelated also to your code.) I'll have to check this as soon as possible (but now I need to go to bed :) ). Many thanks for your interests and this PR.