Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Green lighten to 1 is green #45

Closed
petrohi opened this issue Nov 25, 2014 · 2 comments
Closed

Green lighten to 1 is green #45

petrohi opened this issue Nov 25, 2014 · 2 comments
Labels

Comments

@petrohi
Copy link

petrohi commented Nov 25, 2014

(new Colour('red')).lighten(1).rgb()
Object {r: 255, g: 255, b: 255}
(new Colour('blue')).lighten(1).rgb()
Object {r: 255, g: 255, b: 255}
(new Colour('green')).lighten(1).rgb()
Object {r: 0, g: 255, b: 0}

@MoOx MoOx added the bug label Feb 2, 2015
@MoOx MoOx added the pr welcome label Apr 1, 2015
@rickyvetter
Copy link

This is not actually a bug.

It looks strange because of HTML color spec and because lighten is a relative process.

First, HTML "red" and "blue" are both pure colors to start with (255 for one value and 0 for the others). HTML "green" is strangely only half brightness (128 for green, 0 for the others). If you were to use "lime" instead, you would get the values you want!

For more info on the lighten function being a relative process, see #53. Passing one basically doubles the brightness of the current value. Since "green" is half-bright, it takes that value up to 255 ("lime"). If you were to run (new Colour('green')).lighten(1).lighten(1).rgb() - you would also get the results you were expecting.

@MoOx
Copy link
Collaborator

MoOx commented Jun 2, 2015

Interesting. Thanks for this explanation !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants